Module: Hashie::Extensions::Dash::IndifferentAccess

Defined in:
lib/hashie/extensions/dash/indifferent_access.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
# File 'lib/hashie/extensions/dash/indifferent_access.rb', line 5

def self.included(base)
  base.extend ClassMethods
  base.send :include, Hashie::Extensions::IndifferentAccess
end

.maybe_extend(base) ⇒ Object



10
11
12
13
14
# File 'lib/hashie/extensions/dash/indifferent_access.rb', line 10

def self.maybe_extend(base)
  return unless requires_class_methods?(base)

  base.extend(ClassMethods)
end

Instance Method Details

#to_hObject Also known as: to_hash



22
23
24
25
26
27
28
# File 'lib/hashie/extensions/dash/indifferent_access.rb', line 22

def to_h
  defaults = ::Hash[self.class.properties.map do |prop|
    [Hashie::Extensions::IndifferentAccess.convert_key(prop), self.class.defaults[prop]]
  end]

  defaults.merge(self)
end