Module: Modelish::Configuration
Overview
Configure modelish's behavior on a global level
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 {|_self| ... } ⇒ Object
Configures this module through the given +block+.
-
#ignore_unknown_properties! ⇒ Object
When set, unknown property names will be ignored during initialization and property setting.
-
#raise_errors_on_unknown_properties! ⇒ Object
When set, raise errors during initialization and property setting when unknown property names are encountered.
-
#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.
9 10 11 |
# File 'lib/modelish/configuration.rb', line 9 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
29 30 31 |
# File 'lib/modelish/configuration.rb', line 29 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Configures this module through the given +block+. Default configuration options will be applied unless they are explicitly overridden in the +block+.
41 42 43 44 |
# File 'lib/modelish/configuration.rb', line 41 def configure yield self if block_given? self end |
#ignore_unknown_properties! ⇒ Object
When set, unknown property names will be ignored during initialization and property setting.
15 16 17 |
# File 'lib/modelish/configuration.rb', line 15 def ignore_unknown_properties! self.ignore_unknown_properties = true end |
#raise_errors_on_unknown_properties! ⇒ Object
When set, raise errors during initialization and property setting when unknown property names are encountered. This is the default.
23 24 25 |
# File 'lib/modelish/configuration.rb', line 23 def raise_errors_on_unknown_properties! self.ignore_unknown_properties = false end |
#reset ⇒ Object
Resets this module's configuration.
47 48 49 |
# File 'lib/modelish/configuration.rb', line 47 def reset self.ignore_unknown_properties = false end |