DeltaCloud::ActionObject

Public Class Methods

new(opts={}, &block) click to toggle source
# File lib/base_object.rb, line 190
def initialize(opts={}, &block)
  super(opts)
  @action_urls = opts[:action_urls] || []
  @actions = []
end

Public Instance Methods

action_trigger(action) click to toggle source

This trigger is called right after action. This method does nothing inside ActionObject but it can be redifined and used in meta-programming

# File lib/base_object.rb, line 199
def action_trigger(action)
end
action_urls() click to toggle source
# File lib/base_object.rb, line 223
def action_urls
  actions.collect { |a| a.last }
end
actions() click to toggle source
# File lib/base_object.rb, line 216
def actions
  @objects.inject([]) do |result, item|
    result << [item[:rel], item[:href]] if item[:type].eql?(:action_link)
    result
  end
end
base_method_handler(m, args=[]) click to toggle source
Alias for: method_handler
method_handler(m, args=[]) click to toggle source

First call BaseObject method handler, then, if not method found try ActionObject handler

# File lib/base_object.rb, line 231
def method_handler(m, args=[])
  begin
    base_method_handler(m, args)
  rescue NoHandlerForMethod
    case m[:type]
      when :action_link then do_action(m, args)
      else raise NoHandlerForMethod
    end
  end
end
Also aliased as: base_method_handler
method_missing(name, *args) click to toggle source
# File lib/base_object.rb, line 244
def method_missing(name, *args)
  if name.to_s =~ /^has_(\w+)\?$/
    return actions.any? { |a| a[0] == $1 }
  end
  original_method_missing(name, args)
end
Also aliased as: original_method_missing
original_method_missing(name, *args) click to toggle source
Alias for: method_missing

[Validate]

Generated with the Darkfish Rdoc Generator 2.