Module: Modelish::Configuration
Instance Attribute Summary collapse
-
#ignore_unknown_properties ⇒ Object
If true, ignore unknown property names when initializing new models; otherwise, raise an error when an unknown property is encountered.
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure ⇒ Object
Configures this module through the given +block+.
-
#ignore_unknown_properties! ⇒ Object
When set, unknown property names will be ignored during modelish initialization and property setting.
-
#raise_errors_on_unknown_properties! ⇒ Object
When set, unknown property names will cause errors to be raised when encountered during modelish initialization and property setting.
-
#reset ⇒ Object
Resets this module's configuration.
Instance Attribute Details
#ignore_unknown_properties ⇒ Object
If true, ignore unknown property names when initializing new models; otherwise, raise an error when an unknown property is encountered. Defaults to false.
6 7 8 |
# File 'lib/modelish/configuration.rb', line 6 def ignore_unknown_properties @ignore_unknown_properties end |
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
25 26 27 |
# File 'lib/modelish/configuration.rb', line 25 def self.extended(base) base.reset end |
Instance Method Details
#configure ⇒ Object
Configures this module through the given +block+. Default configuration options will be applied unless they are explicitly overridden in the +block+.
37 38 39 40 41 42 43 |
# File 'lib/modelish/configuration.rb', line 37 def configure if block_given? yield self end self end |
#ignore_unknown_properties! ⇒ Object
When set, unknown property names will be ignored during modelish initialization and property setting.
12 13 14 |
# File 'lib/modelish/configuration.rb', line 12 def ignore_unknown_properties! self.ignore_unknown_properties = true end |
#raise_errors_on_unknown_properties! ⇒ Object
When set, unknown property names will cause errors to be raised when encountered during modelish initialization and property setting. This is the default behavior.
20 21 22 |
# File 'lib/modelish/configuration.rb', line 20 def raise_errors_on_unknown_properties! self.ignore_unknown_properties = false end |
#reset ⇒ Object
Resets this module's configuration.
46 47 48 |
# File 'lib/modelish/configuration.rb', line 46 def reset self.ignore_unknown_properties = false end |