Class: Logux::BaseController

Inherits:
Object
  • Object
show all
Defined in:
lib/logux/base_controller.rb

Direct Known Subclasses

ActionController, ChannelController

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action:, meta: {}) ⇒ BaseController

Returns a new instance of BaseController.



17
18
19
20
# File 'lib/logux/base_controller.rb', line 17

def initialize(action:, meta: {})
  @action = action
  @meta = meta
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



15
16
17
# File 'lib/logux/base_controller.rb', line 15

def action
  @action
end

#metaObject (readonly)

Returns the value of attribute meta.



15
16
17
# File 'lib/logux/base_controller.rb', line 15

def meta
  @meta
end

Class Method Details

.unverify_authorized!Object



10
11
12
# File 'lib/logux/base_controller.rb', line 10

def unverify_authorized!
  Logux.configuration.verify_authorized = false
end

.verify_authorized!Object



6
7
8
# File 'lib/logux/base_controller.rb', line 6

def verify_authorized!
  Logux.configuration.verify_authorized = true
end

Instance Method Details

#node_idObject



33
34
35
# File 'lib/logux/base_controller.rb', line 33

def node_id
  @node_id ||= meta.node_id
end

#respond(status, action: @action, meta: @meta, custom_data: nil) ⇒ Object



22
23
24
25
26
27
# File 'lib/logux/base_controller.rb', line 22

def respond(status, action: @action, meta: @meta, custom_data: nil)
  Logux::Response.new(status,
                      action: action,
                      meta: meta,
                      custom_data: custom_data)
end

#user_idObject



29
30
31
# File 'lib/logux/base_controller.rb', line 29

def user_id
  @user_id ||= meta.user_id
end