class Farscape::RepresentorAgent

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/farscape/representor.rb, line 74
def method_missing(method, *args, &block)
  super
rescue NoMethodError => e
  parameters = args.first || {}
  get_embedded(method) || get_transition(method, parameters, &block) || get_attribute(method) || raise
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/farscape/representor.rb, line 81
def respond_to_missing?(method_name, include_private = false)
  super || [embedded.include?(method_name), method_transitions.include?(method), attributes.include?(method)].any?
end
to_ary() click to toggle source

HACK! - Requires for method_missing; apparently an undocumented feature of Ruby

# File lib/farscape/representor.rb, line 86
def to_ary
end

Private Instance Methods

get_attribute(meth) click to toggle source
# File lib/farscape/representor.rb, line 95
def get_attribute(meth)
  attributes[meth.to_s]
end
get_embedded(meth) click to toggle source
# File lib/farscape/representor.rb, line 91
def get_embedded(meth)
  embedded[meth.to_s]
end
get_transition(meth, request_params = {}, &block) click to toggle source
# File lib/farscape/representor.rb, line 99
def get_transition(meth, request_params = {}, &block)
  return false unless method_transitions.include?(meth = meth.to_s)
  block = ->(*args) { args } unless block_given?
  method_transitions[meth].invoke(request_params) { |x| block.call(x) }
end
method_transitions() click to toggle source
# File lib/farscape/representor.rb, line 105
def method_transitions
  transitions.map { |k,v| @agent.client.safe_method?( v.interface_method ) ? {k => v}  : {k+'!' => v} }.reduce({}, :merge)
end