Sha256: 868713c928b30d5c7858e71be77e97d87441c359084d48bc35781b46ac35e233
Contents?: true
Size: 758 Bytes
Versions: 1
Compression:
Stored size: 758 Bytes
Contents
class Formation::Field < Formation::Element attr_reader :label, :fieldset, :type attr_accessor :value def initialize(name, options = {}) @name = name if @fieldset = options.delete(:fieldset) @fieldset.fields << self end @type = options.delete(:type) || :text @type = Formation::Type.create(self, @type) @label = options.delete(:label) || Formation::Util.titleize(@name) @required = options.delete(:required) || false # Attach any left-over entries as accessors options.each do |key, value| metaclass = class << self; self; end metaclass.send :attr_accessor, key.to_sym send "#{key}=", value end end def field? true end def required? @required end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
formation-0.0.1 | lib/formation/field.rb |