Class: Digup::Setting
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
-
.options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
- .build_functions ⇒ Object
- .content_type_to_handle ⇒ Object
- .enabled? ⇒ Boolean
- .option_to_array(options, key) ⇒ Object
Class Attribute Details
.options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/digup/setting.rb', line 15 def end |
Class Method Details
.build_functions ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/digup/setting.rb', line 17 def build_functions RESPONSE_TYPE.each do |rt| self.class.send(:define_method, "handle_#{rt}?") { [:response_type].include?(rt) } end LOG_TO.each do |lt| self.class.send(:define_method, "log_to_#{lt}?") { [:log_to].include?(lt) } end BOOLEAN_SETTINGS.each do |s| self.class.send(:define_method, "#{s}?") { [s] } end end |
.content_type_to_handle ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/digup/setting.rb', line 56 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
31 32 33 |
# File 'lib/digup/setting.rb', line 31 def enabled? .present? end |
.option_to_array(options, key) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/digup/setting.rb', line 47 def option_to_array(, key) return DEFAULT_SETTINGS[key] unless [key] if [key].is_a? Array [key] else [[key]] end & DEFAULT_SETTINGS[key] end |