Module: Vmodel::ClassMethods
- Defined in:
- lib/vmodel.rb
Instance Method Summary collapse
- #allow_attributes ⇒ Object
- #validates(attribute, type, options = {}) ⇒ Object
- #validations ⇒ Object
- #wild(flag) ⇒ Object
- #wild_mod ⇒ Object
Instance Method Details
#allow_attributes ⇒ Object
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, ={}) if !@_allow_attributes.include?(attribute.to_s) @_allow_attributes << attribute.to_s end @_validations[attribute.to_s]={type: type, options: } end |
#validations ⇒ Object
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_mod ⇒ Object
19 20 21 |
# File 'lib/vmodel.rb', line 19 def wild_mod @_config[:wild_mod] end |