module Hashie::Extensions::Dash::Coercion::ClassMethods
Property declarations supporting coercion.
@example
klass = Class.new(Hashie::Dash) do include Hashie::Extensions::Dash::Coercion property :count, coerce: Integer end klass.new(count: '3').count # => 3
Public Instance Methods
property(property_name, options = {})
click to toggle source
Defines a property on the Dash. Options are the standard ‘Hashie::Dash#property` options plus:
-
‘:coerce` - The class into which you want the property coerced.
@example
klass = Class.new(Hashie::Dash) do include Hashie::Extensions::Dash::Coercion property :count, coerce: Integer end klass.new(count: '3').count # => 3
Calls superclass method
# File lib/hashie/extensions/dash/coercion.rb, line 48 def property(property_name, options = {}) super coerce_key property_name, options[:coerce] if options[:coerce] end