Class: Telegram::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram/controller.rb,
lib/telegram/controller/session.rb,
lib/telegram/controller/renderer.rb,
lib/telegram/controller/view_object.rb

Defined Under Namespace

Modules: Session Classes: Renderer, ViewObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bot_name=(value) ⇒ Object (writeonly)

Sets the attribute bot_name

Parameters:

  • value

    the value to set the attribute bot_name to.



12
13
14
# File 'lib/telegram/controller.rb', line 12

def bot_name=(value)
  @bot_name = value
end

#bots=(value) ⇒ Object

Sets the attribute bots

Parameters:

  • value

    the value to set the attribute bots to.



11
12
13
# File 'lib/telegram/controller.rb', line 11

def bots=(value)
  @bots = value
end

#message=(value) ⇒ Object (writeonly)

Sets the attribute message

Parameters:

  • value

    the value to set the attribute message to.



13
14
15
# File 'lib/telegram/controller.rb', line 13

def message=(value)
  @message = value
end

#params=(value) ⇒ Object

Sets the attribute params

Parameters:

  • value

    the value to set the attribute params to.



14
15
16
# File 'lib/telegram/controller.rb', line 14

def params=(value)
  @params = value
end

Instance Method Details

#dispatch(action) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/telegram/controller.rb', line 17

def dispatch action
  @current_action = action
  self.send action

  render unless @has_response

  @current_action = nil

  # WIP rescue from
end

#expose_instance_variablesObject

TEST



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/telegram/controller.rb', line 39

def expose_instance_variables
  hash = {}
  variables  = instance_variables
  variables -= not_exposed_instance_variables.map { |v| :"@#{v}" }

  variables.each do |name|
    # cut @
    var_name = name[1..-1]
    hash[var_name] = instance_variable_get(name)
  end

  hash
end

#not_exposed_instance_variablesObject



29
30
31
32
33
34
35
# File 'lib/telegram/controller.rb', line 29

def not_exposed_instance_variables
  [
    :bots, :message,
    :current_action, :rendered,
    :bot_name, :has_response,
  ]
end