Module: ReflexBehaviors::ApplicationHelper

Defined in:
app/helpers/reflex_behaviors/application_helper.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



19
20
21
22
23
24
25
26
# File 'app/helpers/reflex_behaviors/application_helper.rb', line 19

def method_missing(name, ...)
  prefixes = %w[toggle_]
  prefixes.each do |prefix|
    next unless name.start_with?(prefix)
    return send("#{prefix}tag_builder").public_send(name.to_s.delete_prefix(prefix), ...)
  end
  super
end

Instance Method Details

#current_partial_pathObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/reflex_behaviors/application_helper.rb', line 6

def current_partial_path
  path = nil
  prefix = "app/views/"
  start = 1
  while path.nil? && start < 100
    location = caller_locations(start, 1).first
    path = location.path if location.path.include?(prefix)
    start += 1
  end
  return "unknown" if path.nil?
  path[(path.index(prefix) + prefix.length), path.rindex("/")]
end

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
# File 'app/helpers/reflex_behaviors/application_helper.rb', line 28

def respond_to_missing?(name, ...)
  prefixes = %w[toggle_]
  prefixes.each do |prefix|
    next unless name.start_with?(prefix)
    return send("#{prefix}tag_builder").respond_to_missing?(name.to_s.delete_prefix(prefix), ...)
  end
  super
end