Module: Sapphire::DSL::Events

Defined in:
lib/sapphire/DSL/Events/For.rb,
lib/sapphire/DSL/Events/Data.rb,
lib/sapphire/DSL/Events/From.rb,
lib/sapphire/DSL/Events/Event.rb,
lib/sapphire/DSL/Events/Where.rb,
lib/sapphire/DSL/Events/Expect.rb,
lib/sapphire/DSL/Events/DataSegment.rb,
lib/sapphire/DSL/Events/Expectation.rb

Defined Under Namespace

Classes: DataSegment, Event, Expectation

Instance Method Summary collapse

Instance Method Details

#Data(item) ⇒ Object



4
5
6
7
8
9
# File 'lib/sapphire/DSL/Events/Data.rb', line 4

def Data(item)
  segment = $events[$currentEvent].GetSegment(item)
  segment ||= DataSegment.new(item)

  $events[$currentEvent].AddSegment(item => segment)
end

#Event(name, &block) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/sapphire/DSL/Events/Event.rb', line 4

def Event(name, &block)
  $events ||= {}
  $events.merge!(name => Event.new(name))
  $currentEvent = name
  block.call()
  $currentEvent = nil
end

#Expect(item) ⇒ Object



4
5
6
7
8
# File 'lib/sapphire/DSL/Events/Expect.rb', line 4

def Expect(item)
  constraint = nil
  constraint = $currentConstraint if !$currentConstraint.nil?
  $events[$currentEvent].AddExpectation(Expectation.new(item, constraint))
end

#From(item) ⇒ Object



4
5
6
7
8
# File 'lib/sapphire/DSL/Events/For.rb', line 4

def From(segment, &block)
  $currentSegment = segment
  block.call()
  $currentSegment = nil
end

#Where(hash, block) ⇒ Object



4
5
6
7
8
# File 'lib/sapphire/DSL/Events/Where.rb', line 4

def Where(hash, block)
  $currentConstraint = hash
  block.call()
  $currentConstraint = nil
end