Class: Digup::Setting

Inherits:
Object show all
Defined in:
lib/digup/setting.rb

Constant Summary collapse

RESPONSE_TYPE =
[:js, :json, :html]
LOG_TO =
[:console, :html_body, :db, :file]
BOOLEAN_SETTINGS =
[:cursor_info]
DEFAULT_SETTINGS =
{
  :response_type => [:js, :json, :html],
  :log_to => [:console, :html_body],
  :cursor_info => true
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.optionsObject

Returns the value of attribute options.



15
16
17
# File 'lib/digup/setting.rb', line 15

def options
  @options
end

Class Method Details

.content_type_to_handleObject



52
53
54
55
56
57
58
# File 'lib/digup/setting.rb', line 52

def content_type_to_handle
  content_type = []
  content_type << 'text/html' if handle_html?
  content_type << 'text/javascript' if handle_js?
  content_type << 'application/json' if handle_json?
  content_type
end

.enabled?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/digup/setting.rb', line 29

def enabled?
  @options.present?
end

.option_to_array(options, key) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/digup/setting.rb', line 44

def option_to_array(options, key)
  if options[key].is_a? Array
    options[key]
  else
    [options[key]]
  end & DEFAULT_SETTINGS[key]
end