Sha256: 6208c0ea5cbdecb9baf5db7c276100188748e876b3165432fc7510c186297e11

Contents?: true

Size: 572 Bytes

Versions: 8

Compression:

Stored size: 572 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.gsub('-','_').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

8 entries across 8 versions & 1 rubygems

Version Path
noodall-form-builder-0.0.13 app/models/noodall/field.rb
noodall-form-builder-0.0.11 app/models/noodall/field.rb
noodall-form-builder-0.0.10 app/models/noodall/field.rb
noodall-form-builder-0.0.9 app/models/noodall/field.rb
noodall-form-builder-0.0.8 app/models/noodall/field.rb
noodall-form-builder-0.0.7 app/models/noodall/field.rb
noodall-form-builder-0.0.6 app/models/noodall/field.rb
noodall-form-builder-0.0.5 app/models/noodall/field.rb