module Core::Gears
service gears
Public Instance Methods
before_confection(&block)
click to toggle source
# File lib/magical/service/core/gears.rb, line 20 def before_confection(&block) config.instance_eval(&block) end
chain() { || ... }
click to toggle source
# File lib/magical/service/core/gears.rb, line 24 def chain config.stages.each { |method| send(*method) } if stages? result = send(*config.delivery) yield result end
clear_virtual_instance_variables()
click to toggle source
# File lib/magical/service/core/gears.rb, line 32 def clear_virtual_instance_variables remove_instance_variable(:@params) if defined?(@params) remove_instance_variable(:@options) if defined?(@options) end
config()
click to toggle source
# File lib/magical/service/core/gears.rb, line 37 def config @config ||= ControlPanel.new end
default_attribute?(attribute, value)
click to toggle source
# File lib/magical/service/core/gears.rb, line 41 def default_attribute?(attribute, value) !config.send(attribute).nil? && value.is_a?(Hash) && value.empty? end
defined_stages?()
click to toggle source
# File lib/magical/service/core/gears.rb, line 45 def defined_stages? config.stages.all? { |phase| respond_to?(phase) } end
delivery?()
click to toggle source
# File lib/magical/service/core/gears.rb, line 49 def delivery? defined?(@config) && !config.delivery.nil? && respond_to?(config.delivery) end
not_defined_error(action)
click to toggle source
# File lib/magical/service/core/gears.rb, line 53 def not_defined_error(action) NoAssignmentError.new(action, self) end
options()
click to toggle source
# File lib/magical/service/core/gears.rb, line 57 def options defined?(@options) ? @options : (@options = config.options) end
params()
click to toggle source
# File lib/magical/service/core/gears.rb, line 61 def params defined?(@params) ? @params : (@params = config.params) end
provide(params: {}, options: {})
click to toggle source
# File lib/magical/service/core/gears.rb, line 9 def provide(params: {}, options: {}) validates_confection do @params = params unless default_attribute?(:params, params) @options = options unless default_attribute?(:options, options) end chain do clear_virtual_instance_variables end end
stages?()
click to toggle source
# File lib/magical/service/core/gears.rb, line 65 def stages? defined?(@config) && !config.stages.nil? end
validates_confection() { || ... }
click to toggle source
# File lib/magical/service/core/gears.rb, line 69 def validates_confection raise not_defined_error('some :stages') if stages? && !defined_stages? raise not_defined_error(':delivery') unless delivery? yield end