lib/eco/api/session/config.rb in eco-helpers-0.9.2 vs lib/eco/api/session/config.rb in eco-helpers-0.9.3

- old
+ new

@@ -22,14 +22,10 @@ def reopen yield(self) end - def cli - self["cli"] ||= Eco::CLI::Config.new - end - def apis self["apis"] ||= Eco::API::Session::Config::Apis.new(config: self) end def logger @@ -138,11 +134,10 @@ end def require(file = nil, match: nil) if match file_manager.dir.dir_files(pattern: match).each do |file| - #pp "#{File.expand_path(file)}" require_relative File.expand_path(file) end else require_relative "#{File.expand_path(file_manager.dir.file(file))}" end @@ -157,12 +152,13 @@ def location_codes org["location_codes"] end def locations_mapper + return @locations_mapper if instance_variable_defined?(:@locations_mapper) file = file_manager.newest(location_codes) - @locations_mapper ||= Eco::Data::Mapper.new(file_manager.load_json(file), internal: :first) + @locations_mapper = Eco::Data::Mapper.new(file_manager.load_json(file), internal: :first) end def tagtree=(file) org["tagtree"] = file end @@ -191,10 +187,14 @@ def session @session ||= Eco::API::Session.new(self) end # PEOPLE + def default_usergroup=(value) + people.default_usergroup = value + end + def discarded_people_file=(value) people.discarded_file = value end def people_cache=(file) @@ -226,32 +226,52 @@ # CUSTOM PERSON PARSERS def person_parser(format: :csv, &block) people.parser(format: format, &block) end - # CUSTOM USE CASES def usecases - cases = self["usecases"] ||= Eco::API::UseCases::UseGroup.new + @usecases = self["usecases"] ||= Eco::API::UseCases.new if block_given? - yield(cases) + yield(@usecases) self else - cases + @usecases end end - # API POLICIES + def post_launch + self["post_launch"] ||= Eco::API::Session::Config::PostLaunch.new(config: self) + end + def policies - api_policies = self["policies"] ||= Eco::API::Policies::UsedPolicies.new + @policies = self["policies"] ||= Eco::API::Policies.new if block_given? - yield(api_policies) + yield(@policies) self else - api_policies + @policies end end + def error_handlers + @error_handlers = self["error_handlers"] ||= Eco::API::Error::Handlers.new + if block_given? + yield(@error_handlers) + self + else + @error_handlers + end + end + + def workflow + @workflow = self["workflow"] ||= Eco::API::Session::Config::Workflow.new(config: self) + @workflow.tap do |wf| + yield(wf) if block_given? + end + end + + end end end end @@ -261,5 +281,7 @@ require_relative 'config/logger' require_relative 'config/mailer' require_relative 'config/s3_storage' require_relative 'config/files' require_relative 'config/people' +require_relative 'config/post_launch' +require_relative 'config/workflow'