class ActionConductor::Exporter

Attributes

arguments[R]
conductor[R]
context[R]

Public Class Methods

new(conductor) click to toggle source
# File lib/action_conductor/exporter.rb, line 6
def initialize(conductor)
  @conductor = conductor
end

Public Instance Methods

export(arguments) click to toggle source
# File lib/action_conductor/exporter.rb, line 10
def export(arguments)
  @arguments = arguments
  output.length == 1 ? output.first : output
end

Private Instance Methods

empty?(args) click to toggle source
# File lib/action_conductor/exporter.rb, line 63
def empty?(args)
  args.empty?
end
enumerable_exports(&block) click to toggle source
# File lib/action_conductor/exporter.rb, line 27
def enumerable_exports(&block)
  selected_exports.to_a.each_with_object([], &block)
end
export_deferred(deferred) click to toggle source
# File lib/action_conductor/exporter.rb, line 31
def export_deferred(deferred)
  deferred.export(conductor, requested_export_value)
end
export_keys() click to toggle source
# File lib/action_conductor/exporter.rb, line 45
def export_keys
  conductor.export_keys
end
exports() click to toggle source
# File lib/action_conductor/exporter.rb, line 41
def exports
  conductor.exports
end
key_value(args) click to toggle source
# File lib/action_conductor/exporter.rb, line 57
def key_value(args)
  return [export_keys, nil]   if empty? args
  return [[args[0]], args[1]] if setter? args
  return [args, nil]
end
output() click to toggle source
# File lib/action_conductor/exporter.rb, line 19
def output
  @output ||= begin
    enumerable_exports do |deferred, exports|
      exports << export_deferred(deferred)
    end
  end
end
requested_export_keys() click to toggle source
# File lib/action_conductor/exporter.rb, line 49
def requested_export_keys
  key_value(arguments)[0]
end
requested_export_value() click to toggle source
# File lib/action_conductor/exporter.rb, line 53
def requested_export_value
  key_value(arguments)[1]
end
selected_exports() click to toggle source
# File lib/action_conductor/exporter.rb, line 35
def selected_exports
  requested_export_keys.map do |key|
    exports.find { |export| export.id == key }
  end
end
setter?(args) click to toggle source
# File lib/action_conductor/exporter.rb, line 67
def setter?(args)
  args[0].is_a? Symbol and !args[1].is_a? Symbol
end