Class: Jsm::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/jsm/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/jsm/validator.rb', line 2

def name
  @name
end

#typeObject (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