Class: BCDD::Data::Object
- Inherits:
-
Object
- Object
- BCDD::Data::Object
- Defined in:
- lib/bcdd/ext/data.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(**kargs) ⇒ Object
constructor
A new instance of Object.
Constructor Details
#initialize(**kargs) ⇒ Object
Returns a new instance of Object.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bcdd/ext/data.rb', line 10 def initialize(**kargs) properties = self.class::Properties attributes = properties.map(kargs) @errors = {} @attributes = if properties.contract? attributes.each_with_object({}) do |(key, value), output| output[key] = value.valid? ? value.value : (errors[key] = value.errors) end else attributes.transform_values!(&:value) end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/bcdd/ext/data.rb', line 8 def attributes @attributes end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/bcdd/ext/data.rb', line 8 def errors @errors end |