Class: BillysBilling::Base
- Inherits:
-
Object
- Object
- BillysBilling::Base
- Extended by:
- Association
- Defined in:
- lib/billys_billing/base.rb
Direct Known Subclasses
Account, Attachment, Contact, DaybookTransaction, Invoice, Line, Organization, Payment, Person, Product, VatModel
Instance Attribute Summary collapse
-
#attrs ⇒ Object
(also: #to_hash)
Returns the value of attribute attrs.
Class Method Summary collapse
-
.lazy_attr_reader(*attrs) ⇒ Object
Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key.
Instance Method Summary collapse
-
#[](method) ⇒ Object
Initializes a new Base object.
-
#initialize(attrs = {}) ⇒ Twitter::Base
constructor
Initializes a new Base object.
Methods included from Association
Constructor Details
#initialize(attrs = {}) ⇒ Twitter::Base
Initializes a new Base object
30 31 32 33 34 35 |
# File 'lib/billys_billing/base.rb', line 30 def initialize(attrs={}) attrs.delete_if{|k,v| v.nil?}.each do |key, value| self.send("#{key}=".to_sym, value) # instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#attrs ⇒ Object Also known as: to_hash
Returns the value of attribute attrs.
7 8 9 |
# File 'lib/billys_billing/base.rb', line 7 def attrs @attrs end |
Class Method Details
.self.lazy_attr_reader(attr) ⇒ Object .self.lazy_attr_reader(attrs) ⇒ Object
Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
16 17 18 19 20 21 22 23 24 |
# File 'lib/billys_billing/base.rb', line 16 def self.lazy_attr_reader(*attrs) attrs.each do |attribute| class_eval do define_method attribute do @attrs[attribute.to_s] end end end end |
Instance Method Details
#[](method) ⇒ Object
Initializes a new Base object
40 41 42 43 44 |
# File 'lib/billys_billing/base.rb', line 40 def [](method) self.__send__(method.to_sym) rescue NoMethodError nil end |