Class: Screenplay::CacheActor
- Defined in:
- lib/screenplay/actors/cache.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Attributes inherited from Actor
Instance Method Summary collapse
Methods inherited from Actor
#configure, descendants, #initialize
Constructor Details
This class inherits a constructor from Screenplay::Actor
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
7 8 9 |
# File 'lib/screenplay/actors/cache.rb', line 7 def cache @cache end |
Instance Method Details
#play(params = {}, input = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/screenplay/actors/cache.rb', line 9 def play(params = {}, input = {}) @cache ||= {} output = {} params.each { | action, values | output = input.dup if action == :merge if action == :clear @cache.clear elsif action == :set values.each { | cache_key, input_key | @cache[cache_key] = (input_key == '$input'.to_sym) ? input : input.get_value_from_path(input_key) puts "\nSet cache #{cache_key} to #{@cache[cache_key]}" if Screenplay.[:debug] } elsif (action == :merge || action == :get) values.each { | input_key, cache_key | puts "\nSet #{input_key.to_sym} to #{@cache[cache_key.to_sym]} from cache key #{cache_key}" if Screenplay.[:debug] output[input_key.to_sym] = @cache[cache_key.to_sym] } end } return output end |