Sha256: 0473bbd38e8a7b0364763f1d8049552876a9bdbcad4cc12e2c05e6a09458826e
Contents?: true
Size: 801 Bytes
Versions: 1
Compression:
Stored size: 801 Bytes
Contents
module Encore class Attribute attr_reader :attribute, :klass, :column, :opts def initialize(klass, column, opts = {}) @klass = klass @column = column @attribute = opts[:as].try(:to_sym) || @column @opts = opts end def assign(object, value) object.send :"#{self.column}=", value end def fetch(object) object.send :"#{self.column}" end def ==(other_attribute) hash == other_attribute.hash end def eql?(other) self == other end # Generate a hash for comparisons def hash [@attribute, @klass].hash end # Return whether the attribute is read-only def readonly? !!@opts[:readonly] end def to_s "#<Encore::Attribute #{@klass}@#{@attribute}>" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
encore-0.0.3 | lib/encore/attribute.rb |