Sha256: 5251a44e4beda196c680e212680ad6dc3c2b6bdf918ce6934182344935f6bfc0
Contents?: true
Size: 966 Bytes
Versions: 5
Compression:
Stored size: 966 Bytes
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 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
5 entries across 5 versions & 1 rubygems