Sha256: 97820e60edd4a35a8fa57c1ecc65a2ae41aeae9745cb31b34363093fe98bcb87
Contents?: true
Size: 934 Bytes
Versions: 2
Compression:
Stored size: 934 Bytes
Contents
module MemoryModel class InvalidFieldError < Error def initialize(name) super("`#{name}` is not a valid field") end end class ReadOnlyFieldError < Error def initialize(name) super("`#{name}` is read only") end end class Base module Fields class Field attr_reader :name, :options def initialize(name, options={}) @name = name.to_sym @options = options.reverse_merge!({ readonly: false, comparable: true }) end def ==(other_object) self.to_sym == other_object.to_sym end def comparable? !!@options[:comparable] end def default @options[:default] end def readonly? !!@options[:readonly] end def to_sym @name.to_sym end def to_s @name.to_s end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
memory_model-1.0.0 | lib/memory_model/base/fields/field.rb |
memory_model-0.1.0 | lib/memory_model/base/fields/field.rb |