Class: Surrogate::Value

Inherits:
Object
  • Object
show all
Defined in:
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

Defined Under Namespace

Classes: BaseValue, BlockValue, Raisable, ValueQueue

Class Method Summary collapse

Class Method Details

.factory(*args, &block) ⇒ Object

convert raw arguments into a value



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

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