Class: TypeConstraints::Meta
- Inherits:
-
Object
- Object
- TypeConstraints::Meta
- Defined in:
- lib/type_constraints/meta.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #check?(val) ⇒ Boolean
- #constraint(v = nil) ⇒ Object
-
#initialize(args = {}) ⇒ Meta
constructor
A new instance of Meta.
Constructor Details
#initialize(args = {}) ⇒ Meta
Returns a new instance of Meta.
5 6 7 8 9 |
# File 'lib/type_constraints/meta.rb', line 5 def initialize(args={}) @name = args[:name] @parent = args[:parent] @constraint = args[:constraint] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/type_constraints/meta.rb', line 4 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
4 5 6 |
# File 'lib/type_constraints/meta.rb', line 4 def parent @parent end |
Instance Method Details
#check?(val) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/type_constraints/meta.rb', line 16 def check?(val) if !parent.nil? && !parent.check?(val) return false end constraint.call(val) end |
#constraint(v = nil) ⇒ Object
11 12 13 14 |
# File 'lib/type_constraints/meta.rb', line 11 def constraint(v=nil) @constraint = v if !v.nil? @constraint end |