Class: Culpa::CallHolder

Inherits:
Object
  • Object
show all
Defined in:
lib/culpa/brickchain_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(brickname, envelope, request, async = false) ⇒ CallHolder



53
54
55
56
57
58
# File 'lib/culpa/brickchain_helpers.rb', line 53

def initialize(brickname, envelope, request, async = false)
  @brickname = brickname
  @envelope = envelope
  @request = request
  @async = async
end

Instance Attribute Details

#threadObject (readonly)

Returns the value of attribute thread.



51
52
53
# File 'lib/culpa/brickchain_helpers.rb', line 51

def thread
  @thread
end

Instance Method Details

#from(action_name) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/culpa/brickchain_helpers.rb', line 60

def from(action_name)
  if @async
    @thread = Thread.new { sub_from(action_name) }
  else
    sub_from(action_name)
  end
end

#get_action(name) ⇒ Object



74
75
76
77
# File 'lib/culpa/brickchain_helpers.rb', line 74

def get_action(name)
  action_name = name.split('_').map(&:capitalize).join
  Actions.const_get(action_name).new(@envelope, @request)
end

#sub_from(action_name) ⇒ Object



68
69
70
71
72
# File 'lib/culpa/brickchain_helpers.rb', line 68

def sub_from(action_name)
  action = get_action(action_name.to_s)
  action.send @brickname
  false
end