Class: ObjectModel::Metadata::Validation
- Inherits:
-
Object
- Object
- ObjectModel::Metadata::Validation
- Defined in:
- lib/ObjectModel/Metadata/validate.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
-
#initialize(method = nil, &block) ⇒ Validation
constructor
A new instance of Validation.
- #validate(entity) ⇒ Object
Constructor Details
#initialize(method = nil, &block) ⇒ Validation
Returns a new instance of Validation.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ObjectModel/Metadata/validate.rb', line 22 def initialize method = nil, &block if method method.should! :be_a, Symbol block.should! :be_nil @method = method elsif block method.should! :be_nil @block = block else should! :be_never_called end end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
20 21 22 |
# File 'lib/ObjectModel/Metadata/validate.rb', line 20 def block @block end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
20 21 22 |
# File 'lib/ObjectModel/Metadata/validate.rb', line 20 def method @method end |
Instance Method Details
#validate(entity) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/ObjectModel/Metadata/validate.rb', line 35 def validate entity if @method entity.send @method elsif @block entity.instance_eval &@block else should! :be_never_called end end |