Class: GuestyAPI::Entities::Base
- Inherits:
-
Object
- Object
- GuestyAPI::Entities::Base
- Defined in:
- lib/guesty_api/entities/base.rb
Direct Known Subclasses
Account, Guest, GuestConversation, Listing, Reservation, User, Webhook
Instance Attribute Summary collapse
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Instance Method Summary collapse
-
#initialize(payload) ⇒ Base
constructor
A new instance of Base.
- #method_missing(method) ⇒ Object
- #respond_to_missing?(method) ⇒ Boolean
Constructor Details
#initialize(payload) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/guesty_api/entities/base.rb', line 8 def initialize(payload) @raw_data = payload @methods = payload.keys.map(&:to_sym) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
13 14 15 16 |
# File 'lib/guesty_api/entities/base.rb', line 13 def method_missing(method, *) super unless @methods.include? method @raw_data[method.to_s] end |
Instance Attribute Details
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
6 7 8 |
# File 'lib/guesty_api/entities/base.rb', line 6 def raw_data @raw_data end |
Instance Method Details
#respond_to_missing?(method) ⇒ Boolean
18 19 20 21 22 |
# File 'lib/guesty_api/entities/base.rb', line 18 def respond_to_missing?(method, *) return true if @methods.include? method super end |