Class: ViewPartialFormBuilder::HtmlAttributes
- Inherits:
-
Object
- Object
- ViewPartialFormBuilder::HtmlAttributes
show all
- Defined in:
- lib/view_partial_form_builder/html_attributes.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of HtmlAttributes.
11
12
13
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 11
def initialize(**attributes)
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 33
def method_missing(method_name, *arguments, &block)
if attributes.respond_to?(method_name)
return_value = attributes.public_send(method_name, *arguments, &block)
if return_value.kind_of?(Hash)
HtmlAttributes.new(return_value)
else
return_value
end
else
super
end
end
|
Instance Method Details
#merge_token_lists(**token_list_attributes) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 15
def merge_token_lists(**token_list_attributes)
merge(
token_list_attributes.reduce({}) do |merged, (key, value)|
token_list = Array(attributes.delete(key)).unshift(value)
merged.merge(key => token_list.flatten.uniq)
end
)
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
47
48
49
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 47
def respond_to_missing?(method_name, include_private = false)
attributes.respond_to?(method_name) || super
end
|
#to_h ⇒ Object
25
26
27
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 25
def to_h
attributes.to_h
end
|
#to_hash ⇒ Object
29
30
31
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 29
def to_hash
attributes.to_hash
end
|