Class: Compendium::Presenters::Settings::Query
- Inherits:
-
Object
- Object
- Compendium::Presenters::Settings::Query
- Defined in:
- app/classes/compendium/presenters/settings/query.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ Query
constructor
A new instance of Query.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ Query
Returns a new instance of Query.
5 6 7 |
# File 'app/classes/compendium/presenters/settings/query.rb', line 5 def initialize @settings = {}.with_indifferent_access end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/classes/compendium/presenters/settings/query.rb', line 9 def method_missing(name, *args, &block) if block_given? @settings[name] = block.call(*args) elsif !args.empty? @settings[name] = args.length == 1 ? args.first : args elsif name.to_s.end_with?('?') prefix = name.to_s.gsub(/\?\z/, '') @settings.key?(prefix) else @settings[name] end end |