Class: Surrogate::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/surrogate/values.rb,
lib/surrogate/values.rb

Overview

Superclass for all types of values. Where a value is anything stored in an instance variable on a surrogate, intended to be returned by an api method

Direct Known Subclasses

MethodQueue, Raisable, Recursive

Defined Under Namespace

Classes: MethodQueue, Raisable, Recursive

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Value

Returns a new instance of Value.



21
22
23
# File 'lib/surrogate/values.rb', line 21

def initialize(value)
  @value = value
end

Class Method Details

.factory(*args, &block) ⇒ Object

convert raw arguments into a value



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/surrogate/values.rb', line 8

def self.factory(*args, &block)
  arg = args.first
  if args.size > 1
    MethodQueue.new args
  elsif arg.kind_of? Exception
    Raisable.new arg
  elsif arg.kind_of? Value
    Recursive.new arg
  else
    Value.new arg
  end
end

Instance Method Details

#factory(*args, &block) ⇒ Object



29
30
31
# File 'lib/surrogate/values.rb', line 29

def factory(*args, &block)
  self.class.factory(*args, &block)
end

#value(hatchling, method_name) ⇒ Object



25
26
27
# File 'lib/surrogate/values.rb', line 25

def value(hatchling, method_name)
  @value
end