Class: SmartHash::Loose

Inherits:
SmartHash show all
Defined in:
lib/smart_hash/loose.rb

Overview

Non-strict SmartHash

person = SmartHash::Loose[]

is equivalent to:

person = SmartHash[]
person.strict = false

Constant Summary

Constant Summary

Constants inherited from SmartHash

ATTR_REGEXP, FORBIDDEN_ATTRS, VERSION

Instance Attribute Summary

Attributes inherited from SmartHash

#declared_attrs, #protected_attrs, #strict

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SmartHash

#declare, #protect, #undeclare, #unprotect

Constructor Details

#initialize(*args) ⇒ Loose

See SmartHash#initialize.



12
13
14
15
# File 'lib/smart_hash/loose.rb', line 12

def initialize(*args)
  super
  @strict = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SmartHash

Class Method Details

.[](*args) ⇒ Object

See SmartHash::[].



18
19
20
21
22
# File 'lib/smart_hash/loose.rb', line 18

def self.[](*args)
  super.tap do |_|
    _.strict = false
  end
end