Class: RailsAjax::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-ajax/configuration.rb

Overview

Class used to configure and store the configuration of RailsAjax

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Constructor



23
24
25
26
27
28
29
# File 'lib/rails-ajax/configuration.rb', line 23

def initialize
  # Set default values here
  @enabled = true
  @main_container = 'body'
  @flash_containers = {}
  @debug_alerts = false
end

Instance Method Details

#debug_alerts(switch) ⇒ Object

Do we activate debugging alerts ?

Parameters
  • switch (Boolean): Do we activate debugging alerts ?



65
66
67
# File 'lib/rails-ajax/configuration.rb', line 65

def debug_alerts(switch)
  @debug_alerts = switch
end

#debug_alerts?Boolean

Debug alerts ?

Return
  • Boolean: Do we switch on debug alerts?

Returns:

  • (Boolean)


18
19
20
# File 'lib/rails-ajax/configuration.rb', line 18

def debug_alerts?
  return @debug_alerts
end

#enable(switch) ⇒ Object

Do we activate RailsAjax ?

Parameters
  • switch (Boolean): Do we activate RailsAjax ?



35
36
37
# File 'lib/rails-ajax/configuration.rb', line 35

def enable(switch)
  @enabled = switch
end

#enabled?Boolean

Indicate if RailsAjax is enabled

Return
  • Boolean: Is rails-ajax enabled?

Returns:

  • (Boolean)


10
11
12
# File 'lib/rails-ajax/configuration.rb', line 10

def enabled?
  return @enabled
end

#flash_containers(selectors_map = nil) ⇒ Object

Define the flash containers (add them to already present ones) if provided, and return them

Parameters
  • selectors_map (map<Symbol,String>): The map of selectors, per flash message type (:alert, :noticeā€¦)

Return
  • map<Symbol,String>: The map of selectors [optional = nil]



56
57
58
59
# File 'lib/rails-ajax/configuration.rb', line 56

def flash_containers(selectors_map = nil)
  @flash_containers.merge!(selectors_map) if (selectors_map != nil)
  return @flash_containers
end

#main_container(selector = nil) ⇒ Object

Define the main container if provided, and return it

Parameters
  • selector (String): Selector used to identify the container [optional = nil]

Return
  • String: The CSS selector of the main container



45
46
47
48
# File 'lib/rails-ajax/configuration.rb', line 45

def main_container(selector = nil)
  @main_container = selector if (selector != nil)
  return @main_container
end