Class: Alula::Meta
Instance Attribute Summary collapse
-
#custom_attributes ⇒ Object
readonly
Returns the value of attribute custom_attributes.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #fetch(key, *args, &block) ⇒ Object
-
#initialize(meta) ⇒ Meta
constructor
A new instance of Meta.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(meta) ⇒ Meta
Returns a new instance of Meta.
5 6 7 8 9 10 11 12 |
# File 'lib/alula/meta.rb', line 5 def initialize() = coerce_to_hash() page_data = extract_page() build_pagination(page_data) @custom_attributes = build_custom_attributes() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
22 23 24 25 26 |
# File 'lib/alula/meta.rb', line 22 def method_missing(method_name, *args, &block) return custom_attributes[method_name] if custom_attributes.key?(method_name) super end |
Instance Attribute Details
#custom_attributes ⇒ Object (readonly)
Returns the value of attribute custom_attributes.
3 4 5 |
# File 'lib/alula/meta.rb', line 3 def custom_attributes @custom_attributes end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
3 4 5 |
# File 'lib/alula/meta.rb', line 3 def number @number end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/alula/meta.rb', line 3 def page @page end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
3 4 5 |
# File 'lib/alula/meta.rb', line 3 def size @size end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
3 4 5 |
# File 'lib/alula/meta.rb', line 3 def total @total end |
Instance Method Details
#[](key) ⇒ Object
14 15 16 |
# File 'lib/alula/meta.rb', line 14 def [](key) custom_attributes[normalize_key(key)] end |
#fetch(key, *args, &block) ⇒ Object
18 19 20 |
# File 'lib/alula/meta.rb', line 18 def fetch(key, *args, &block) custom_attributes.fetch(normalize_key(key), *args, &block) end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
28 29 30 |
# File 'lib/alula/meta.rb', line 28 def respond_to_missing?(method_name, include_private = false) custom_attributes.key?(method_name) || super end |