Class: Phlex::Rails::Builder
- Inherits:
-
BasicObject
- Defined in:
- lib/phlex/rails/builder.rb
Instance Method Summary
collapse
Constructor Details
#initialize(object, component:) ⇒ Builder
Returns a new instance of Builder.
4
5
6
7
|
# File 'lib/phlex/rails/builder.rb', line 4
def initialize(object, component:)
@object = object
@component = component
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(&block) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/phlex/rails/builder.rb', line 25
def method_missing(*, **, &block)
output = if block
@object.public_send(*, **) do |builder|
yield ::Phlex::Rails::Builder.new(builder, component: @component)
end
else
@object.public_send(*, **)
end
case output
when ::ActiveSupport::SafeBuffer
@component.raw(output)
else
output
end
end
|
Instance Method Details
#inspect ⇒ Object
13
14
15
|
# File 'lib/phlex/rails/builder.rb', line 13
def inspect
"Phlex::Rails::Builder(#{@object.inspect})"
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
21
22
23
|
# File 'lib/phlex/rails/builder.rb', line 21
def respond_to_missing?(method_name, include_private = false)
@object.respond_to?(method_name, include_private)
end
|
#unwrap ⇒ Object
17
18
19
|
# File 'lib/phlex/rails/builder.rb', line 17
def unwrap
@object
end
|