Module: Modelish::Configuration

Included in:
Modelish, Base
Defined in:
lib/modelish/configuration.rb

Overview

Configure modelish's behavior on a global level

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ignore_unknown_propertiesObject

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+.

Examples:

Disable raising errors on unknown property names

Modelish.configure do |config|
  config.ignore_unknown_properties = true
end

Yields:

  • (_self)

Yield Parameters:



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.

See Also:

  • {raise_errors_on_unknown_properties!}


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.

See Also:

  • {ignore_unknown_properties!}


23
24
25
# File 'lib/modelish/configuration.rb', line 23

def raise_errors_on_unknown_properties!
  self.ignore_unknown_properties = false
end

#resetObject

Resets this module's configuration.



47
48
49
# File 'lib/modelish/configuration.rb', line 47

def reset
  self.ignore_unknown_properties = false
end