Method: AttrJson::Model.attr_json_config
- Defined in:
- lib/attr_json/model.rb
.attr_json_config(new_values = {}) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/attr_json/model.rb', line 112 def attr_json_config(new_values = {}) if new_values.present? # get one without new values, then merge new values into it, and # set it locally for this class. @attr_json_config = attr_json_config.merge(new_values) else if instance_variable_defined?("@attr_json_config") # we have a custom one for this class, return it. @attr_json_config elsif superclass.respond_to?(:attr_json_config) # return superclass without setting it locally, so changes in superclass # will continue effecting us. superclass.attr_json_config else # no superclass, no nothing, set it to blank one. @attr_json_config = Config.new(mode: :model) end end end |