Class: ViewModel::Record::AttributeData
- Inherits:
-
Object
- Object
- ViewModel::Record::AttributeData
- Defined in:
- lib/view_model/record/attribute_data.rb
Instance Attribute Summary collapse
-
#attribute_serializer ⇒ Object
readonly
Returns the value of attribute attribute_serializer.
-
#attribute_viewmodel ⇒ Object
readonly
Returns the value of attribute attribute_viewmodel.
-
#model_attr_name ⇒ Object
readonly
Returns the value of attribute model_attr_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #array? ⇒ Boolean
- #association? ⇒ Boolean
-
#initialize(name:, model_attr_name:, attribute_viewmodel:, attribute_serializer:, array:, read_only:, write_once:) ⇒ AttributeData
constructor
A new instance of AttributeData.
- #map_value(value) ⇒ Object
- #read_only? ⇒ Boolean
- #using_serializer? ⇒ Boolean
- #using_viewmodel? ⇒ Boolean
- #write_once? ⇒ Boolean
Constructor Details
#initialize(name:, model_attr_name:, attribute_viewmodel:, attribute_serializer:, array:, read_only:, write_once:) ⇒ AttributeData
Returns a new instance of AttributeData.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/view_model/record/attribute_data.rb', line 6 def initialize(name:, model_attr_name:, attribute_viewmodel:, attribute_serializer:, array:, read_only:, write_once:) @name = name @model_attr_name = model_attr_name @attribute_viewmodel = attribute_viewmodel @attribute_serializer = attribute_serializer @array = array @read_only = read_only @write_once = write_once end |
Instance Attribute Details
#attribute_serializer ⇒ Object (readonly)
Returns the value of attribute attribute_serializer.
4 5 6 |
# File 'lib/view_model/record/attribute_data.rb', line 4 def attribute_serializer @attribute_serializer end |
#attribute_viewmodel ⇒ Object (readonly)
Returns the value of attribute attribute_viewmodel.
4 5 6 |
# File 'lib/view_model/record/attribute_data.rb', line 4 def attribute_viewmodel @attribute_viewmodel end |
#model_attr_name ⇒ Object (readonly)
Returns the value of attribute model_attr_name.
4 5 6 |
# File 'lib/view_model/record/attribute_data.rb', line 4 def model_attr_name @model_attr_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/view_model/record/attribute_data.rb', line 4 def name @name end |
Instance Method Details
#array? ⇒ Boolean
26 27 28 |
# File 'lib/view_model/record/attribute_data.rb', line 26 def array? @array end |
#association? ⇒ Boolean
22 23 24 |
# File 'lib/view_model/record/attribute_data.rb', line 22 def association? false end |
#map_value(value) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/view_model/record/attribute_data.rb', line 46 def map_value(value) if array? value.map { |v| yield(v) } else yield(value) end end |
#read_only? ⇒ Boolean
30 31 32 |
# File 'lib/view_model/record/attribute_data.rb', line 30 def read_only? @read_only end |
#using_serializer? ⇒ Boolean
38 39 40 |
# File 'lib/view_model/record/attribute_data.rb', line 38 def using_serializer? !@attribute_serializer.nil? end |
#using_viewmodel? ⇒ Boolean
42 43 44 |
# File 'lib/view_model/record/attribute_data.rb', line 42 def using_viewmodel? !@attribute_viewmodel.nil? end |
#write_once? ⇒ Boolean
34 35 36 |
# File 'lib/view_model/record/attribute_data.rb', line 34 def write_once? @write_once end |