Class: ResourceKitling::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/resource_kitling.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Action

Returns a new instance of Action.



20
21
22
23
24
25
# File 'lib/resource_kitling.rb', line 20

def initialize(name)
  @name = name
  @verb = :get
  @version = 'v1'
  @path = path
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/resource_kitling.rb', line 18

def name
  @name
end

Instance Method Details

#generated_path(values = {}) ⇒ Object



44
45
46
47
48
# File 'lib/resource_kitling.rb', line 44

def generated_path(values = {})
  values.inject("/#{version}/#{path}") do |np, (key, value)|
    np.gsub(":#{key}", value.to_s)
  end
end

#path(path = nil, &block) ⇒ Object



37
38
39
40
41
42
# File 'lib/resource_kitling.rb', line 37

def path(path = nil, &block)
  raise "You must pass either a block or a string for paths" if path and block_given?
  @path = path if path
  @path = block if block_given?
  @path
end

#to_sObject



50
51
52
# File 'lib/resource_kitling.rb', line 50

def to_s
  name
end

#verb(v = nil) ⇒ Object



27
28
29
30
# File 'lib/resource_kitling.rb', line 27

def verb(v = nil)
  @verb = v if v
  @verb
end

#version(v = nil) ⇒ Object



32
33
34
35
# File 'lib/resource_kitling.rb', line 32

def version(v = nil)
  @version = v if v
  @version
end