Sha256: 2535d3fba12025155887fd33b94a1e4ee8c32c4e6cc734851e35025848e66fe7

Contents?: true

Size: 576 Bytes

Versions: 4

Compression:

Stored size: 576 Bytes

Contents

module  Noodall
  class Field
    include MongoMapper::EmbeddedDocument
  
    key :_type, String, :required => true
    key :name, String, :required => true
    key :label, String
    key :default, String
    key :required, Boolean, :default => false, :required => true
  
    embedded_in :form
    
    def underscored_name
      name.parameterize('_').to_s
    end
    
    def default_class(response)
      'default-value' if response.send(underscored_name.to_sym) == default
    end
  
    def mandatory?
      Form::MANDATORY_FIELDS.include?(self.name)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
noodall-form-builder-0.0.4 app/models/noodall/field.rb
noodall-form-builder-0.0.3 app/models/noodall/field.rb
noodall-form-builder-0.0.2 app/models/noodall/field.rb
noodall-form-builder-0.0.1 app/models/noodall/field.rb