module Light::Services::Outputs

Attributes

outputs[RW]
outputs[RW]

Getters

Public Class Methods

included(base) click to toggle source
# File lib/light/services/outputs.rb, line 6
def self.included(base)
  base.extend ClassMethods
  base.class_eval do
    class << self
      attr_accessor :outputs
    end
  end
end

Private Instance Methods

all_outputs() click to toggle source
# File lib/light/services/outputs.rb, line 33
def all_outputs
  return @_all_outputs if defined?(@_all_outputs)
  @_all_outputs = self.class.ancestors.select { |klass| klass.ancestors.include?(::Light::Services::Base) }
                      .map(&:outputs).compact.flatten.uniq
end
generate_outputs_methods() click to toggle source
# File lib/light/services/outputs.rb, line 46
def generate_outputs_methods
  outputs.keys.each do |output_name|
    define_singleton_method output_name do
      outputs[output_name]
    end

    define_singleton_method "#{output_name}=" do |value|
      outputs[output_name] = value
    end
  end
end
initialize_outputs() click to toggle source
# File lib/light/services/outputs.rb, line 23
def initialize_outputs
  self.outputs = {}

  all_outputs.each do |options|
    store_output(options)
  end

  generate_outputs_methods
end
store_output(options) click to toggle source
# File lib/light/services/outputs.rb, line 39
def store_output(options)
  output_name  = options[:name]
  output_value = options[:value]

  outputs[output_name] = output_value
end