Class: Phlex::Rails::Builder
- Inherits:
- BasicObject
- Defined in:
- lib/phlex/rails/builder.rb
Instance Method Summary collapse
-
#initialize(object, component:) ⇒ Builder
constructor
A new instance of Builder.
- #method_missing(&block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/phlex/rails/builder.rb', line 15 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
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
11 12 13 |
# File 'lib/phlex/rails/builder.rb', line 11 def respond_to_missing?(method_name, include_private = false) @object.respond_to?(method_name, include_private) end |