Sha256: 8faa45a982deedfdb2bb02f6b60c262b5a35713ed317cff751a23ad0100b62c5

Contents?: true

Size: 739 Bytes

Versions: 26

Compression:

Stored size: 739 Bytes

Contents

module Hashie
  module Extensions
    module Dash
      module Coercion
        # Extends a Dash with the ability to define coercion for properties.

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

        module ClassMethods
          # Defines a property on the Dash. Options are the standard
          # <tt>Hashie::Dash#property</tt> options plus:
          #
          # * <tt>:coerce</tt> - The class into which you want the property coerced.
          def property(property_name, options = {})
            super
            coerce_key property_name, options[:coerce] if options[:coerce]
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 24 versions & 5 rubygems

Version Path
hashie-3.4.6 lib/hashie/extensions/dash/coercion.rb
hashie-3.4.5 lib/hashie/extensions/dash/coercion.rb
hashie-3.4.4 lib/hashie/extensions/dash/coercion.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/hashie-3.4.3/lib/hashie/extensions/dash/coercion.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/hashie-3.4.3/lib/hashie/extensions/dash/coercion.rb
hashie-3.4.3 lib/hashie/extensions/dash/coercion.rb