Sha256: 033fa139215f9d21da2b6838629d304ecd77d26b30ca1f95e7277267a06e8f3a
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
module Representable # Created at class compile time. Keeps configuration options for one property. class Definition attr_reader :name, :options alias_method :getter, :name def initialize(sym, options={}) @name = sym.to_s @options = options end def clone self.class.new(name, options.clone) # DISCUSS: make generic Definition.cloned_attribute that passes list to constructor. end def setter :"#{name}=" end def typed? sought_type.is_a?(Class) or representer_module # also true if only :extend is set, for people who want solely rendering. end def array? options[:collection] end def hash? options[:hash] end def sought_type options[:class] end def from (options[:from] || name).to_s end def default options[:default] ||= [] if array? # FIXME: move to CollectionBinding! options[:default] end def representer_module options[:extend] end def attribute options[:attribute] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
representable-1.1.7 | lib/representable/definition.rb |
representable-1.1.6 | lib/representable/definition.rb |
representable-1.1.5 | lib/representable/definition.rb |