Class: TypedFormModel::PropMetadata
- Inherits:
-
Data
- Object
- Data
- TypedFormModel::PropMetadata
- Defined in:
- lib/typed_form_model/prop_metadata.rb
Overview
Per-prop metadata captured at declaration time for options that Literal
doesn't know about (model-mapping, transforms). Immutable value object.
model and attribute are the parsed pieces of the DSL from: kwarg
(a Symbol fills only attribute; a "src.attr" String fills both).
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#transform ⇒ Object
readonly
Returns the value of attribute transform.
Instance Method Summary collapse
-
#maps_to?(model_name) ⇒ Boolean
Is this prop mapped to the given source name (the first segment of a dotted
from:)?. -
#model_attribute(prop_name) ⇒ Object
The target attribute name on the model; defaults to the prop name when
from:did not specify a rename.
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute
8 9 10 |
# File 'lib/typed_form_model/prop_metadata.rb', line 8 def attribute @attribute end |
#model ⇒ Object (readonly)
Returns the value of attribute model
8 9 10 |
# File 'lib/typed_form_model/prop_metadata.rb', line 8 def model @model end |
#transform ⇒ Object (readonly)
Returns the value of attribute transform
8 9 10 |
# File 'lib/typed_form_model/prop_metadata.rb', line 8 def transform @transform end |
Instance Method Details
#maps_to?(model_name) ⇒ Boolean
Is this prop mapped to the given source name (the first segment of a
dotted from:)?
15 |
# File 'lib/typed_form_model/prop_metadata.rb', line 15 def maps_to?(model_name) = model == model_name |
#model_attribute(prop_name) ⇒ Object
The target attribute name on the model; defaults to the prop name
when from: did not specify a rename.
11 |
# File 'lib/typed_form_model/prop_metadata.rb', line 11 def model_attribute(prop_name) = attribute || prop_name |