Module: Volt::AttributeScope::ClassMethods

Defined in:
lib/volt/server/html_parser/attribute_scope.rb

Instance Method Summary collapse

Instance Method Details

#methodize_string(str) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/volt/server/html_parser/attribute_scope.rb', line 5

def methodize_string(str)
  # Convert the string passed in to the binding so it returns a ruby Method
  # instance
  parts = str.split('.')

  end_call = parts.last.strip

  # If no method(args) is passed, we assume they want to convert the method
  # to a Method, to be called with *args (from any trigger's), then event.
  if str !~ /[\[\]\$\@\=]/ && end_call =~ /[_a-z0-9!?]+$/
    parts[-1] = "method(:#{end_call})"

    str = parts.join('.')
  end

  str
end