Class: YamlStore::BlockBased::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/yaml_store/block_based.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Condition

Returns a new instance of Condition.



8
9
10
# File 'lib/yaml_store/block_based.rb', line 8

def initialize(&block)
  self.block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



4
5
6
# File 'lib/yaml_store/block_based.rb', line 4

def block
  @block
end

#negatedObject

Returns the value of attribute negated.



5
6
7
# File 'lib/yaml_store/block_based.rb', line 5

def negated
  @negated
end

Instance Method Details

#negated?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/yaml_store/block_based.rb', line 12

def negated?
  @negated == true
end

#run(record) ⇒ Object



16
17
18
19
# File 'lib/yaml_store/block_based.rb', line 16

def run(record)
  result = block.call(record)
  negated? ? !result : result
end