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.
3
4
5
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 3
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
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 25
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
7
8
9
10
11
12
13
14
15
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 7
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
39
40
41
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 39
def respond_to_missing?(method_name, include_private = false)
attributes.respond_to?(method_name) || super
end
|
#to_h ⇒ Object
17
18
19
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 17
def to_h
attributes.to_h
end
|
#to_hash ⇒ Object
21
22
23
|
# File 'lib/view_partial_form_builder/html_attributes.rb', line 21
def to_hash
attributes.to_hash
end
|