Class: PeakFlowUtils::HandlerHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/peak_flow_utils/handler_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ HandlerHelper

Returns a new instance of HandlerHelper.



12
13
14
# File 'lib/peak_flow_utils/handler_helper.rb', line 12

def initialize(data)
  @data = data
end

Class Method Details

.find(id) ⇒ Object

Raises:

  • (ActiveRecord::RecordNotFound)


4
5
6
7
8
9
10
# File 'lib/peak_flow_utils/handler_helper.rb', line 4

def self.find(id)
  PeakFlowUtils::HandlersFinderService.execute!.each do |handler|
    return handler if handler.id == id.to_s
  end

  raise ActiveRecord::RecordNotFound, "Handlers not found: '#{id}'."
end

Instance Method Details

#constObject



28
29
30
# File 'lib/peak_flow_utils/handler_helper.rb', line 28

def const
  PeakFlowUtils.const_get(@data.fetch(:const_name))
end

#groupsObject



36
37
38
# File 'lib/peak_flow_utils/handler_helper.rb', line 36

def groups
  const.new.groups
end

#idObject



16
17
18
# File 'lib/peak_flow_utils/handler_helper.rb', line 16

def id
  @data.fetch(:id)
end

#instanceObject



32
33
34
# File 'lib/peak_flow_utils/handler_helper.rb', line 32

def instance
  const.new
end

#nameObject



24
25
26
# File 'lib/peak_flow_utils/handler_helper.rb', line 24

def name
  @data.fetch(:name)
end

#to_paramObject



20
21
22
# File 'lib/peak_flow_utils/handler_helper.rb', line 20

def to_param
  id
end