class Decidim::TermCustomizer::Context::JobContext
Public Instance Methods
resolve!()
click to toggle source
# File lib/decidim/term_customizer/context/job_context.rb, line 7 def resolve! # Figure out the organization and user through the job arguments if # passed for the job. user = nil data[:job].arguments.each do |arg| @organization ||= organization_from_argument(arg) @space ||= space_from_argument(arg) @component ||= component_from_argument(arg) user ||= arg if arg.is_a?(Decidim::User) end # In case a component was found, define the space as the component # space to avoid any conflicts. @space = component.participatory_space if component # In case a space was found, define the organization as the space # organization to avoid any conflicts. @organization = space.organization if space # In case an organization could not be resolved any other way, check # it through the user (if the user was passed). @organization ||= user.organization if user end
Protected Instance Methods
component_from_argument(arg)
click to toggle source
# File lib/decidim/term_customizer/context/job_context.rb, line 45 def component_from_argument(arg) return arg if arg.is_a?(Decidim::Component) arg.component if arg.respond_to?(:component) end
organization_from_argument(arg)
click to toggle source
# File lib/decidim/term_customizer/context/job_context.rb, line 33 def organization_from_argument(arg) return arg if arg.is_a?(Decidim::Organization) arg.organization if arg.respond_to?(:organization) end
space_from_argument(arg)
click to toggle source
# File lib/decidim/term_customizer/context/job_context.rb, line 39 def space_from_argument(arg) return arg if arg.is_a?(Decidim::Participable) arg.participatory_space if arg.respond_to?(:participatory_space) end