Class: Telegem::Types::BaseType
- Inherits:
-
Object
- Object
- Telegem::Types::BaseType
- Defined in:
- lib/api/types.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#_raw_data ⇒ Object
readonly
Returns the value of attribute _raw_data.
Instance Method Summary collapse
-
#initialize(data) ⇒ BaseType
constructor
A new instance of BaseType.
- #method_missing(name, *args) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(data) ⇒ BaseType
Returns a new instance of BaseType.
4 5 6 |
# File 'lib/api/types.rb', line 4 def initialize(data) @_raw_data = data || {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/api/types.rb', line 8 def method_missing(name, *args) key = name.to_s return @_raw_data[key] if @_raw_data.key?(key) camel_key = snake_to_camel(key) return @_raw_data[camel_key] if @_raw_data.key?(camel_key) super end |
Instance Attribute Details
#_raw_data ⇒ Object (readonly)
Returns the value of attribute _raw_data.
24 25 26 |
# File 'lib/api/types.rb', line 24 def _raw_data @_raw_data end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
18 19 20 21 22 |
# File 'lib/api/types.rb', line 18 def respond_to_missing?(name, include_private = false) key = name.to_s camel_key = snake_to_camel(key) @_raw_data.key?(key) || @_raw_data.key?(camel_key) || super end |