Class: HaveAPI::Client::Resource
- Inherits:
-
Object
- Object
- HaveAPI::Client::Resource
- Defined in:
- lib/haveapi/client/resource.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prepared_args ⇒ Object
Returns the value of attribute prepared_args.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
-
#initialize(api, name) ⇒ Resource
constructor
A new instance of Resource.
- #setup(description) ⇒ Object
- #setup_from_clone(original) ⇒ Object
Constructor Details
#initialize(api, name) ⇒ Resource
Returns a new instance of Resource.
5 6 7 8 9 |
# File 'lib/haveapi/client/resource.rb', line 5 def initialize(api, name) @api = api @name = name @prepared_args = [] end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
2 3 4 |
# File 'lib/haveapi/client/resource.rb', line 2 def actions @actions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/haveapi/client/resource.rb', line 2 def name @name end |
#prepared_args ⇒ Object
Returns the value of attribute prepared_args.
3 4 5 |
# File 'lib/haveapi/client/resource.rb', line 3 def prepared_args @prepared_args end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
2 3 4 |
# File 'lib/haveapi/client/resource.rb', line 2 def resources @resources end |
Instance Method Details
#setup(description) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/haveapi/client/resource.rb', line 11 def setup(description) @actions = {} @resources = {} description[:actions].each do |name, desc| action = HaveAPI::Client::Action.new(@api, name, desc, []) define_action(action) @actions[name] = action end description[:resources].each do |name, desc| r = HaveAPI::Client::Resource.new(@api, name) r.setup(desc) define_resource(r) @resources[name] = r end end |
#setup_from_clone(original) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/haveapi/client/resource.rb', line 29 def setup_from_clone(original) original.actions.each_value do |action| define_action(action) end original.resources.each_value do |resource| define_resource(resource) end end |