Class: Fixturama::Loader::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/fixturama/loader/context.rb

Overview

The context bound to some fixture

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)



32
33
34
35
36
37
# File 'lib/fixturama/loader/context.rb', line 32

def method_missing(name, *args, &block)
  return @values[name] if @values.key?(name)
  return super unless @example.respond_to?(name)

  @example.send(name, *args, &block)
end

Instance Method Details

#[](key) ⇒ Object

Get value by key



14
15
16
# File 'lib/fixturama/loader/context.rb', line 14

def [](key)
  @values.send(key).instance_variable_get(:@value)
end

#object(value) ⇒ Object



7
8
9
# File 'lib/fixturama/loader/context.rb', line 7

def object(value)
  Marshal.dump(value).dump
end