Class: Billogram::Resource
- Inherits:
-
Object
- Object
- Billogram::Resource
- Defined in:
- lib/billogram/resource.rb
Direct Known Subclasses
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(attributes = {}) ⇒ Resource
constructor
A new instance of Resource.
- #update(attributes = {}) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Resource
Returns a new instance of Resource.
28 29 30 |
# File 'lib/billogram/resource.rb', line 28 def initialize(attributes = {}) @attributes = Hashie::Mash.new(attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/billogram/resource.rb', line 42 def method_missing(method, *args) method_name = method.to_s if method_name =~ /(=|\?)$/ case $1 when '=' attributes[$`] = args.first when '?' attributes[$`] end else if attributes.respond_to?(method) attributes[method] else super end end end |
Class Attribute Details
.endpoint ⇒ Object
6 7 8 |
# File 'lib/billogram/resource.rb', line 6 def endpoint @endpoint || downcased_class_name end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
26 27 28 |
# File 'lib/billogram/resource.rb', line 26 def attributes @attributes end |
Class Method Details
.get(id = '') ⇒ Object
10 11 12 |
# File 'lib/billogram/resource.rb', line 10 def get(id = '') get_and_return_new("/#{endpoint}/#{id}") end |