Class: ViewModels::Extensions::ModelReader::Options
- Inherits:
-
Object
- Object
- ViewModels::Extensions::ModelReader::Options
- Defined in:
- lib/view_models/extensions/model_reader.rb
Overview
Bundles the model reader options and extracts the relevant structured data.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
-
#initialize(*attributes_and_options) ⇒ Options
constructor
A new instance of Options.
-
#split(options) ⇒ Object
Extract filter_through options from the options hash if there are any.
-
#to_a ⇒ Array
Render the options to an array.
Constructor Details
#initialize(*attributes_and_options) ⇒ Options
Returns a new instance of Options.
38 39 40 |
# File 'lib/view_models/extensions/model_reader.rb', line 38 def initialize * split end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
36 37 38 |
# File 'lib/view_models/extensions/model_reader.rb', line 36 def attributes @attributes end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
36 37 38 |
# File 'lib/view_models/extensions/model_reader.rb', line 36 def filters @filters end |
Instance Method Details
#split(options) ⇒ Object
Extract filter_through options from the options hash if there are any.
45 46 47 48 49 50 51 52 |
# File 'lib/view_models/extensions/model_reader.rb', line 45 def split @filters = if .last.kind_of?(Hash) [*(.pop[:filter_through])].reverse else [] end @attributes = end |
#to_a ⇒ Array
Render the options to an array
57 58 59 |
# File 'lib/view_models/extensions/model_reader.rb', line 57 def to_a [attributes, filters] end |