Class: Croudia::Base
- Inherits:
-
Object
- Object
- Croudia::Base
- Defined in:
- lib/croudia/base.rb
Direct Known Subclasses
AccessToken, Entities, Entity::Media, Identity, Relationship, Source
Class Method Summary collapse
Instance Method Summary collapse
-
#[](name) ⇒ Object
Fetch an attribute.
- #attrs ⇒ Hash (also: #to_h, #to_hash)
-
#initialize(attrs = {}) ⇒ Croudia::Base
constructor
Initialize a new object.
Constructor Details
#initialize(attrs = {}) ⇒ Croudia::Base
Initialize a new object
17 18 19 |
# File 'lib/croudia/base.rb', line 17 def initialize(attrs = {}) @attrs = attrs || {} end |
Class Method Details
.attr_reader(*attrs) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/croudia/base.rb', line 4 def attr_reader(*attrs) attrs.each do |attr| define_method(attr) do @attrs[attr.to_s] || @attrs[attr.to_sym] end end end |
Instance Method Details
#[](name) ⇒ Object
Fetch an attribute
24 25 26 27 28 |
# File 'lib/croudia/base.rb', line 24 def [](name) __send__(name.to_sym) rescue NoMethodError nil end |
#attrs ⇒ Hash Also known as: to_h, to_hash
31 32 33 |
# File 'lib/croudia/base.rb', line 31 def attrs @attrs end |