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

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

Instance Method Summary collapse

Instance Method Details

#property?(name) ⇒ Boolean

Check to see if the specified property has already been defined.

Returns:

  • (Boolean)

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

def property?(name)
  name = translations[name.to_sym] if translation_for?(name)
  name = name.to_s
  !!properties.find { |property| property.to_s == name }
end

#transformation_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)

41
42
43
44
# File 'lib/hashie/extensions/dash/indifferent_access.rb', line 41

def transformation_exists?(name)
  name = name.to_s
  !!transforms.keys.find { |key| key.to_s == name }
end

#transformed_property(property_name, value) ⇒ Object


36
37
38
39
# File 'lib/hashie/extensions/dash/indifferent_access.rb', line 36

def transformed_property(property_name, value)
  transform = transforms[property_name] || transforms[property_name.to_sym]
  transform.call(value)
end

#translation_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)

31
32
33
34
# File 'lib/hashie/extensions/dash/indifferent_access.rb', line 31

def translation_exists?(name)
  name = name.to_s
  !!translations.keys.find { |key| key.to_s == name }
end