Class: DataGuru::ModelConfiguration
- Inherits:
-
Object
- Object
- DataGuru::ModelConfiguration
- Defined in:
- lib/data_guru/model_configuration.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Instance Method Summary collapse
- #attributes(config_data) ⇒ Object
-
#initialize(model:, model_name: default_model_name(model)) ⇒ ModelConfiguration
constructor
A new instance of ModelConfiguration.
- #permitted_attributes(config_data) ⇒ Object
- #required_attributes(config_data) ⇒ Object
Constructor Details
#initialize(model:, model_name: default_model_name(model)) ⇒ ModelConfiguration
Returns a new instance of ModelConfiguration.
5 6 7 8 |
# File 'lib/data_guru/model_configuration.rb', line 5 def initialize(model:, model_name: default_model_name(model)) @model = model @model_name = model_name end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/data_guru/model_configuration.rb', line 3 def model @model end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
3 4 5 |
# File 'lib/data_guru/model_configuration.rb', line 3 def model_name @model_name end |
Instance Method Details
#attributes(config_data) ⇒ Object
10 11 12 |
# File 'lib/data_guru/model_configuration.rb', line 10 def attributes(config_data) config_data[model_name] end |
#permitted_attributes(config_data) ⇒ Object
14 15 16 |
# File 'lib/data_guru/model_configuration.rb', line 14 def permitted_attributes(config_data) attributes(config_data).map{ |k, _v| k.to_sym } end |
#required_attributes(config_data) ⇒ Object
18 19 20 |
# File 'lib/data_guru/model_configuration.rb', line 18 def required_attributes(config_data) attributes(config_data).map{ |k, v| v["required"] ? k.to_sym : nil }.reject(&:nil?) end |