Class: AR2DTO::ModelConfig
- Inherits:
-
Object
- Object
- AR2DTO::ModelConfig
- Defined in:
- lib/ar2dto/model_config.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#model_config ⇒ Object
readonly
Returns the value of attribute model_config.
Instance Method Summary collapse
- #active_model_compliance ⇒ Object
- #class_name ⇒ Object
- #except ⇒ Object
-
#initialize(model) ⇒ ModelConfig
constructor
A new instance of ModelConfig.
- #namespace ⇒ Object
- #namespaced_class_name ⇒ Object
- #setup_config(model_config) ⇒ Object
Constructor Details
#initialize(model) ⇒ ModelConfig
Returns a new instance of ModelConfig.
7 8 9 |
# File 'lib/ar2dto/model_config.rb', line 7 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/ar2dto/model_config.rb', line 5 def model @model end |
#model_config ⇒ Object (readonly)
Returns the value of attribute model_config.
5 6 7 |
# File 'lib/ar2dto/model_config.rb', line 5 def model_config @model_config end |
Instance Method Details
#active_model_compliance ⇒ Object
15 16 17 |
# File 'lib/ar2dto/model_config.rb', line 15 def active_model_compliance @active_model_compliance ||= global_config.active_model_compliance end |
#class_name ⇒ Object
23 24 25 |
# File 'lib/ar2dto/model_config.rb', line 23 def class_name @class_name ||= namespaced_class_name.split("::").last end |
#except ⇒ Object
19 20 21 |
# File 'lib/ar2dto/model_config.rb', line 19 def except @except ||= Array(global_config.except) | Array(model_config[:except]) end |
#namespace ⇒ Object
27 28 29 |
# File 'lib/ar2dto/model_config.rb', line 27 def namespace @namespace ||= namespaced_class_name.deconstantize.presence&.constantize || Object end |
#namespaced_class_name ⇒ Object
31 32 33 |
# File 'lib/ar2dto/model_config.rb', line 31 def namespaced_class_name @namespaced_class_name ||= model_config[:class_name] || model_name_replaced_suffix end |
#setup_config(model_config) ⇒ Object
11 12 13 |
# File 'lib/ar2dto/model_config.rb', line 11 def setup_config(model_config) @model_config ||= model_config end |