Module: Vmodel::ClassMethods

Defined in:
lib/vmodel.rb

Instance Method Summary collapse

Instance Method Details

#allow_attributesObject



23
24
25
26
27
# File 'lib/vmodel.rb', line 23

def allow_attributes(*argv)
  if !wild_mod
    @_allow_attributes = argv.map(&:to_s)
  end
end

#validates(attribute, type, options = {}) ⇒ Object



33
34
35
36
37
38
# File 'lib/vmodel.rb', line 33

def validates(attribute, type, options={})
  if !@_allow_attributes.include?(attribute.to_s)
    @_allow_attributes << attribute.to_s
  end
  @_validations[attribute.to_s]={type: type, options: options}
end

#validationsObject



40
41
42
# File 'lib/vmodel.rb', line 40

def validations
  @_validations
end

#wild(flag) ⇒ Object



15
16
17
# File 'lib/vmodel.rb', line 15

def wild(flag)
  @_config[:wild_mod] = flag
end

#wild_modObject



19
20
21
# File 'lib/vmodel.rb', line 19

def wild_mod
  @_config[:wild_mod]
end