Module: Atomsphere::Action::ClassMethods

Defined in:
lib/atomsphere/action.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
# File 'lib/atomsphere/action.rb', line 7

def self.included base
end

Instance Method Details

#fieldsObject



15
16
17
18
19
# File 'lib/atomsphere/action.rb', line 15

def fields
  %w(required one_of optional).map do |m|
    self.class.class_variable_get :"@@#{m}"
  end.flatten
end

#initialize(params = {}) ⇒ Object



10
11
12
13
# File 'lib/atomsphere/action.rb', line 10

def initialize params={}
  set_params params
  validate!
end

#runObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/atomsphere/action.rb', line 21

def run
  @api_response ||= api_client.send(*[
    api_method,
    action,
    api_method.eql?(:get) ? nil : request
  ].compact)

  @response ||= @api_response.to_hash
  self
end