Class: Jsm::Validator
- Inherits:
-
Object
- Object
- Jsm::Validator
- Defined in:
- lib/jsm/validator.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, name, &block) ⇒ Validator
constructor
A new instance of Validator.
- #validate(obj) ⇒ Object
Constructor Details
#initialize(type, name, &block) ⇒ Validator
Returns a new instance of Validator.
3 4 5 6 7 |
# File 'lib/jsm/validator.rb', line 3 def initialize(type, name, &block) @type = type @name = name @block = block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/jsm/validator.rb', line 2 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/jsm/validator.rb', line 2 def type @type end |
Instance Method Details
#validate(obj) ⇒ Object
9 10 11 |
# File 'lib/jsm/validator.rb', line 9 def validate(obj) @block.call(obj) end |