Sha256: fd15e0a07e0d13122de7890a62c82c9f791062f6f9425ffadf9a027b471708e2

Contents?: true

Size: 768 Bytes

Versions: 50

Compression:

Stored size: 768 Bytes

Contents

module MongoModel
  module AttributeMethods
    module BeforeTypeCast
      extend ActiveSupport::Concern
      
      included do
        attribute_method_suffix "_before_type_cast"
      end
      
      # Returns an attribute value before typecasting.
      def read_attribute_before_type_cast(name)
        attributes.before_type_cast(name.to_sym)
      end
      
      # Returns a hash of attributes before typecasting.
      def attributes_before_type_cast
        attributes.keys.inject({}) do |result, key|
          result[key] = attributes.before_type_cast(key)
          result
        end
      end
      
    private
      def attribute_before_type_cast(attribute_name)
        read_attribute_before_type_cast(attribute_name)
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
mongomodel-0.5.5 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.5.4 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.5.3 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.5.2 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.5.1 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.5.0 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.9 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.8 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.7 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.6 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.5 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.4 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.3 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.2 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.1 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.4.0 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.3.6 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.3.5 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.3.4 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb
mongomodel-0.3.3 lib/mongomodel/concerns/attribute_methods/before_type_cast.rb