Class: RufletView

Inherits:
Object
  • Object
show all
Includes:
Ruflet::UI::SharedControlForwarders
Defined in:
lib/ruflet/rails/view.rb

Overview

RufletView is the base class for all server-driven Ruflet views in a Rails app. It includes Ruflet::UI::SharedControlForwarders so that all widget builder methods (text, column, row, container, safe_area, filled_button, …) are available directly on the view instance — the same way showcase uses them.

Direct Known Subclasses

Ruflet::Rails::ResourceView

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ RufletView

Returns a new instance of RufletView.



45
46
47
# File 'lib/ruflet/rails/view.rb', line 45

def initialize(page)
  @page = page
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



12
13
14
# File 'lib/ruflet/rails/view.rb', line 12

def page
  @page
end

Class Method Details

.inherited(child) ⇒ Object



20
21
22
23
# File 'lib/ruflet/rails/view.rb', line 20

def inherited(child)
  super
  Ruflet::Rails.register_view(child) if defined?(Ruflet::Rails) && Ruflet::Rails.respond_to?(:register_view)
end

.render(page, *args, **kwargs, &block) ⇒ Object



41
42
43
# File 'lib/ruflet/rails/view.rb', line 41

def self.render(page, *args, **kwargs, &block)
  new(page).render(*args, **kwargs, &block)
end

.route(path = nil) ⇒ Object



15
16
17
18
# File 'lib/ruflet/rails/view.rb', line 15

def route(path = nil)
  @route_path = normalize_route(path) if path
  @route_path || inferred_route
end