Class: Noodall::Form

Inherits:
Object
  • Object
show all
Includes:
MongoMapper::Document
Defined in:
app/models/noodall/form.rb

Constant Summary collapse

MANDATORY_FIELDS =
['Name','Email']

Instance Method Summary collapse

Instance Method Details

#boolean_fieldsObject



38
39
40
# File 'app/models/noodall/form.rb', line 38

def boolean_fields
  self.fields.select{|f| f.class == Noodall::CheckBox }
end

#create_mandatory_fields!Object



46
47
48
49
50
51
52
# File 'app/models/noodall/form.rb', line 46

def create_mandatory_fields!
  MANDATORY_FIELDS.each do |mf|
    if fields.blank? or fields.select{|f| f.name == mf }.empty?
      self.fields << Noodall::TextField.new(:name => mf, :required => true)
    end
  end
end

#required_fieldsObject



42
43
44
# File 'app/models/noodall/form.rb', line 42

def required_fields
  self.fields.select{|f| f.required }
end