Class: ResourceKitling::Action
- Inherits:
-
Object
- Object
- ResourceKitling::Action
- Defined in:
- lib/resource_kitling.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #generated_path(values = {}) ⇒ Object
-
#initialize(name) ⇒ Action
constructor
A new instance of Action.
- #path(path = nil, &block) ⇒ Object
- #to_s ⇒ Object
- #verb(v = nil) ⇒ Object
- #version(v = nil) ⇒ Object
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
#name ⇒ Object (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_s ⇒ Object
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 |