Sha256: 7cc5a395e0a83c64537596ef59c35521ea5353491653a3f7258ffeb3f634d2d6

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

module Recliner
  module AttributeMethods
    module Read
      extend ActiveSupport::Concern
      
      included do
        attribute_method_suffix ""
      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)
        if prop = property(name)
          attributes[prop.as]
        else
          attributes[name.to_s]
        end
      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

1 entries across 1 versions & 1 rubygems

Version Path
recliner-0.0.1 lib/recliner/attribute_methods/read.rb