lib/eco/api/session/config.rb in eco-helpers-2.1.12 vs lib/eco/api/session/config.rb in eco-helpers-2.2.1
- old
+ new
@@ -44,10 +44,16 @@
# Helper to send emails.
# @return [Eco::API::Session::Config::Mailer]
def mailer
self["mailer"] ||= Eco::API::Session::Config::Mailer.new(config: self)
end
+
+ # Helper scope reporting structures.
+ # @return [Eco::API::Session::Config::TagTree]
+ def tagtree_config
+ org["tagtree_config"] ||= Eco::API::Session::Config::TagTree.new(config: self)
+ end
# @!endgroup
# @!group Logger
# @return [Eco::API::Session::Config::Logger]
@@ -223,39 +229,24 @@
file = file_manager.newest(location_codes)
@locations_mapper = Eco::Data::Mapper.new(file_manager.load_json(file), internal: :first)
end
def tagtree=(file)
- org["tagtree"] = file
+ tagtree_config.file = file
end
- # It uses the `tagtree.json` file and in its absence, if `graphql` enabled, the `life_tagtree`
+ # It uses the `tagtree.json` file and in its absence, if `graphql` enabled, the largest `life_tagtree`
# @return [Eco::API::Organization::TagTree]
def tagtree(enviro: nil)
- return @tagtree if instance_variable_defined?(:@tagtree) && @tagtree.enviro == enviro
- if tree_file = org["tagtree"]
- tree = []
- tree = file_manager.load_json(tree_file) unless !tree_file
- @tagtree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
- else
- @tagtree = live_tree(enviro: enviro)
- end
+ @tagtree ||= tagtree_config.scope_tree(enviro: enviro)
end
# It obtains the first of the live tagtree in the org
# @note it requires graphql connection configuration parameters
# @return [Eco::API::Organization::TagTree]
def live_tree(enviro: nil)
- return @live_tree if instance_variable_defined?(:@live_tree) && @live_tree.enviro == enviro
- if apis.active_api.version_available?(:graphql)
- graphql = apis.api(version: :graphql)
- if tree = graphql.currentOrganization.tagTrees.to_a.first.treeify
- @live_tree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
- else
- @live_tree = nil
- end
- end
+ @live_tree ||= tagtree_config.live_tree(enviro: enviro)
end
# @return [Eco::API::Organization::PolicyGroups]
def policy_groups
return @policy_groups if instance_variable_defined?(:@policy_groups)
@@ -413,7 +404,8 @@
require_relative 'config/mailer'
require_relative 'config/sftp'
require_relative 'config/s3_storage'
require_relative 'config/files'
require_relative 'config/people'
+require_relative 'config/tagtree'
require_relative 'config/post_launch'
require_relative 'config/workflow'