Sha256: 83ae749a225e941d618ee5e426d00174d973b5cce492d5587a7d73017271c0f0

Contents?: true

Size: 723 Bytes

Versions: 4

Compression:

Stored size: 723 Bytes

Contents

module  Noodall
  class Field
    include MongoMapper::EmbeddedDocument
    plugin MongoMapper::Plugins::MultiParameterAttributes

    key :_type, String, :required => true
    key :name, String, :required => true
    key :label, String
    key :default, String
    key :required, Boolean, :default => false

    embedded_in :form

    before_save :default_label
    def default_label
      self.label = self.name if self.label.blank?
    end

    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

4 entries across 4 versions & 1 rubygems

Version Path
noodall-form-builder-0.5.4 app/models/noodall/field.rb
noodall-form-builder-0.5.3 app/models/noodall/field.rb
noodall-form-builder-0.5.2 app/models/noodall/field.rb
noodall-form-builder-0.5.0 app/models/noodall/field.rb