Class: Zx::Reflect

Inherits:
Object
  • Object
show all
Defined in:
lib/zx/reflect.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, tag) ⇒ Reflect

Returns a new instance of Reflect.



7
8
9
10
# File 'lib/zx/reflect.rb', line 7

def initialize(result, tag)
  self.result = result
  self.tag = tag
end

Instance Attribute Details

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/zx/reflect.rb', line 5

def result
  @result
end

#tagObject

Returns the value of attribute tag.



5
6
7
# File 'lib/zx/reflect.rb', line 5

def tag
  @tag
end

Class Method Details

.apply(result, tag, &block) ⇒ Object



18
19
20
# File 'lib/zx/reflect.rb', line 18

def self.apply(result, tag, &block)
  new(result, tag).apply(&block)
end

Instance Method Details

#apply(&block) ⇒ Object



12
13
14
15
16
# File 'lib/zx/reflect.rb', line 12

def apply(&block)
  return block.call(result.value, [result.type, result.success?]) if tag.nil?

  block.call(result.value, [result.type, result.success?]) if result.type == tag.to_sym
end