Module: Val::DSL
- Included in:
- Val
- Defined in:
- lib/val.rb
Instance Method Summary collapse
- #is(array) ⇒ Object
- #is_a(type) ⇒ Object
- #key(name, *conditions) ⇒ Object
- #m(name, &block) ⇒ Object
- #NOT(question) ⇒ Object
- #OR(*values) ⇒ Object
- #val(&block) ⇒ Object
Instance Method Details
#is_a(type) ⇒ Object
12 13 14 |
# File 'lib/val.rb', line 12 def is_a type is [:is_a?, type] end |
#key(name, *conditions) ⇒ Object
16 17 18 19 |
# File 'lib/val.rb', line 16 def key name, *conditions conditions = [NotNil] if conditions.empty? @claims += conditions.map { |condition| Key.new name, condition } end |
#m(name, &block) ⇒ Object
33 34 35 36 37 |
# File 'lib/val.rb', line 33 def m name, &block = Message.new name .instance_exec &block if block_given? @claims << end |
#NOT(question) ⇒ Object
27 28 29 30 |
# File 'lib/val.rb', line 27 def NOT question claim = -> it { not it.send question } @claims << claim end |
#OR(*values) ⇒ Object
22 23 24 25 |
# File 'lib/val.rb', line 22 def OR *values claim = -> it { values.any? &[:===, it] } @claims << claim end |
#val(&block) ⇒ Object
3 4 5 |
# File 'lib/val.rb', line 3 def val &block self.class.new &block end |