Class: HaveAPI::Client::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/client/action.rb

Instance Method Summary collapse

Constructor Details

#initialize(api, name, spec, args) ⇒ Action

Returns a new instance of Action.



4
5
6
7
8
9
10
# File 'lib/haveapi/client/action.rb', line 4

def initialize(api, name, spec, args)
  @api = api
  @name = name
  @spec = spec

  apply_args(args)
end

Instance Method Details

#auth?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/haveapi/client/action.rb', line 22

def auth?
  @spec[:auth]
end

#execute(*args) ⇒ Object



12
13
14
15
16
# File 'lib/haveapi/client/action.rb', line 12

def execute(*args)
  ret = @api.call(self, *args)
  @prepared_url = nil
  ret
end

#http_methodObject



59
60
61
# File 'lib/haveapi/client/action.rb', line 59

def http_method
  @spec[:method]
end

#inputObject



26
27
28
# File 'lib/haveapi/client/action.rb', line 26

def input
  @spec[:input]
end

#layoutObject



34
35
36
# File 'lib/haveapi/client/action.rb', line 34

def layout
  @spec[:output][:layout]
end

#nameObject



18
19
20
# File 'lib/haveapi/client/action.rb', line 18

def name
  @name
end

#namespace(src) ⇒ Object



42
43
44
# File 'lib/haveapi/client/action.rb', line 42

def namespace(src)
  @spec[src][:namespace]
end

#outputObject



30
31
32
# File 'lib/haveapi/client/action.rb', line 30

def output
  @spec[:output]
end

#paramsObject



46
47
48
# File 'lib/haveapi/client/action.rb', line 46

def params
  @spec[:output][:parameters]
end

#prepared_urlObject

Url with resolved parameters.



55
56
57
# File 'lib/haveapi/client/action.rb', line 55

def prepared_url
  @prepared_url || @spec[:url]
end

#provide_args(*args) ⇒ Object



67
68
69
# File 'lib/haveapi/client/action.rb', line 67

def provide_args(*args)
  apply_args(args)
end

#structureObject



38
39
40
# File 'lib/haveapi/client/action.rb', line 38

def structure
  @spec[:output][:format]
end

#unresolved_args?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/haveapi/client/action.rb', line 63

def unresolved_args?
  prepared_url =~ /:[a-zA-Z\-_]+/
end

#urlObject



50
51
52
# File 'lib/haveapi/client/action.rb', line 50

def url
  @spec[:url]
end