Module: DataGuru::Model
- Defined in:
- lib/data_guru/model.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#permitted_attributes ⇒ Object
readonly
Returns the value of attribute permitted_attributes.
-
#required_attributes ⇒ Object
readonly
Returns the value of attribute required_attributes.
Instance Method Summary collapse
- #attributes ⇒ Object
- #initialize(key, attrs, config, config_data) ⇒ Object
- #missing_attributes ⇒ Object
- #valid? ⇒ Boolean
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/data_guru/model.rb', line 3 def id @id end |
#permitted_attributes ⇒ Object (readonly)
Returns the value of attribute permitted_attributes.
3 4 5 |
# File 'lib/data_guru/model.rb', line 3 def permitted_attributes @permitted_attributes end |
#required_attributes ⇒ Object (readonly)
Returns the value of attribute required_attributes.
3 4 5 |
# File 'lib/data_guru/model.rb', line 3 def required_attributes @required_attributes end |
Instance Method Details
#attributes ⇒ Object
17 18 19 |
# File 'lib/data_guru/model.rb', line 17 def attributes @attributes ||= all_attributes end |
#initialize(key, attrs, config, config_data) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/data_guru/model.rb', line 5 def initialize(key, attrs, config, config_data) @id = key @permitted_attributes = config.permitted_attributes(config_data) @required_attributes = config.required_attributes(config_data) permitted_attributes.each do |attribute| set_attr_getter(attribute) default_value = config.attributes(config_data)[attribute.to_s]["default_value"] set_attr_value(attribute, attrs[attribute.to_s], default_value) end end |
#missing_attributes ⇒ Object
25 26 27 |
# File 'lib/data_guru/model.rb', line 25 def missing_attributes required_attributes - present_required_attributes end |
#valid? ⇒ Boolean
21 22 23 |
# File 'lib/data_guru/model.rb', line 21 def valid? present_required_attributes == required_attributes end |