class Fixturama::Loader::Context
@private The context bound to some fixture
Public Class Methods
new(example, values)
click to toggle source
# File lib/fixturama/loader/context.rb 20 def initialize(example, values) 21 @example = example 22 @values = \ 23 Hash(values).each_with_object(Hashie::Mash.new) do |(key, val), obj| 24 obj[key] = Value.new(key, val) 25 end 26 end
Public Instance Methods
[](key)
click to toggle source
Get value by key @param [#to_s] key @return [Object]
# File lib/fixturama/loader/context.rb 14 def [](key) 15 @values.send(key).instance_variable_get(:@value) 16 end
object(value)
click to toggle source
# File lib/fixturama/loader/context.rb 7 def object(value) 8 Marshal.dump(value).dump 9 end
Private Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/fixturama/loader/context.rb 32 def method_missing(name, *args, &block) 33 return @values[name] if @values.key?(name) 34 return super unless @example.respond_to?(name) 35 36 @example.send(name, *args, &block) 37 end
respond_to_missing?(name, *)
click to toggle source
Calls superclass method
# File lib/fixturama/loader/context.rb 28 def respond_to_missing?(name, *) 29 @values.key?(name) || @example.respond_to?(name) || super 30 end