Sha256: 19eef2f412f204337a2c56e3fe235db929f23e81a6068a8aa6b2e7084ca69a29

Contents?: true

Size: 1017 Bytes

Versions: 12

Compression:

Stored size: 1017 Bytes

Contents

module MongoModel
  module AttributeMethods
    module Read
      extend ActiveSupport::Concern
      
      # ActiveModel 3.2 defines the non-prefixed attribute name automatically
      if ActiveModel::VERSION::STRING <= "3.2"
        included do
          attribute_method_suffix ""
        end
      end
      
      # Returns the value of the attribute identified by +name+ after it has been typecast (for example,
      # "2004-12-12" in a date property is cast to a date object, like Date.new(2004, 12, 12)).
      def read_attribute(name)
        attributes[name.to_sym]
      end
      
      # Returns the value of the attribute identified by <tt>name</tt> after it has been typecast (for example,
      # "2004-12-12" in a date property is cast to a date object, like Date.new(2004, 12, 12)).
      # (Alias for read_attribute).
      def [](name)
        read_attribute(name)
      end
    
    private
      def attribute(attribute_name)
        read_attribute(attribute_name)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mongomodel-0.5.5 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.5.4 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.5.3 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.5.2 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.5.1 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.5.0 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.4.9 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.4.8 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.4.7 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.4.6 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.4.5 lib/mongomodel/concerns/attribute_methods/read.rb
mongomodel-0.4.4 lib/mongomodel/concerns/attribute_methods/read.rb