Module: Heartml::ServerEffects::JSPropertyAliases

Defined in:
lib/heartml/server_effects.rb

Overview

rubocop:disable Naming/MethodName

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, **kwargs) ⇒ Object

rubocop:disable Style/MissingRespondToMissing



15
16
17
18
19
20
21
22
23
24
# File 'lib/heartml/server_effects.rb', line 15

def method_missing(meth, *args, **kwargs) # rubocop:disable Style/MissingRespondToMissing
  return super unless meth.to_s.end_with?("=")

  kebob_cased = meth.to_s
                    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1-\2')
                    .gsub(/([a-z\d])([A-Z])/, '\1-\2')
                    .downcase

  self[kebob_cased.delete_suffix("=")] = args[0]
end

Instance Method Details

#innerHTML=(value) ⇒ Object



11
12
13
# File 'lib/heartml/server_effects.rb', line 11

def innerHTML=(value)
  self.inner_html = value
end

#textContent=(value) ⇒ Object



7
8
9
# File 'lib/heartml/server_effects.rb', line 7

def textContent=(value)
  self.content = value
end