Class: Lookbook::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/lookbook/engine.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.preview_controllerObject (readonly)

Returns the value of attribute preview_controller.



163
164
165
# File 'lib/lookbook/engine.rb', line 163

def preview_controller
  @preview_controller
end

Class Method Details

.mounted_pathObject



155
156
157
# File 'lib/lookbook/engine.rb', line 155

def mounted_path
  Lookbook::Engine.routes.find_script_name({})
end

.parserObject



159
160
161
# File 'lib/lookbook/engine.rb', line 159

def parser
  @parser ||= Lookbook::Parser.new(config.lookbook.preview_paths, config.lookbook.parser_registry_path)
end

.websocketObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/lookbook/engine.rb', line 132

def websocket
  return @websocket unless @websocket.nil?
  if config.lookbook.auto_refresh
    cable = ActionCable::Server::Configuration.new
    cable.cable = {adapter: "async"}.with_indifferent_access
    cable.mount_path = config.lookbook.cable_mount_path
    cable.connection_class = -> { Lookbook::Connection }
    cable.logger = config.lookbook.cable_logger

    @websocket ||= if Rails.version.to_f >= 6.0
      ActionCable::Server::Base.new(config: cable)
    else
      @websocket ||= ActionCable::Server::Base.new
      @websocket.config = cable
      @websocket
    end
  end
end

.websocket_mount_pathObject



151
152
153
# File 'lib/lookbook/engine.rb', line 151

def websocket_mount_path
  "#{mounted_path}#{config.lookbook.cable_mount_path}" if websocket
end