Class: Sortah::Lens

Inherits:
Component show all
Defined in:
lib/sortah/components/lens.rb

Instance Attribute Summary

Attributes inherited from Component

#block, #name

Instance Method Summary collapse

Methods inherited from Component

#defined?, #initialize, #run_dependencies!

Constructor Details

This class inherits a constructor from Sortah::Component

Instance Method Details

#clear_state!Object



32
# File 'lib/sortah/components/lens.rb', line 32

def clear_state!; @ran = false; end

#run!(email, context) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/sortah/components/lens.rb', line 22

def run!(email, context)
  @email = email
  return if already_ran?
  #XXX: this can be moved to the cleanroom, then the mark_as_run! can be put
  #after the appropriate 
  run_dependencies!(email, context)
  result = run_block!
  email.(name, result) if provides_value?
end

#valid?(context) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/sortah/components/lens.rb', line 16

def valid?(context)
  dependencies.each do |lens|
    raise ParseErrorException unless context.include? lens
  end
end