Class: Sitemap::Configuration
- Inherits:
-
Object
- Object
- Sitemap::Configuration
- Defined in:
- lib/sitemap/configuration.rb
Defined Under Namespace
Modules: Defaults
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #method_missing(method, *args, &block) ⇒ Object
- #params ⇒ Object
- #reset ⇒ Object
- #search ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 |
# File 'lib/sitemap/configuration.rb', line 23 def initialize reset end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sitemap/configuration.rb', line 44 def method_missing(method, *args, &block) if /^(?<prefix>search|params)?_?(?<name>[a-z\_]+)(?<setter>=)?/ =~ method if prefix if setter self.data[prefix.to_sym][name.to_sym] = args.first else data[prefix.to_sym][name.to_sym] end else if setter self.data[name.to_sym] = args.first else data[name.to_sym] end end else super(method, *args, &block) end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
21 22 23 |
# File 'lib/sitemap/configuration.rb', line 21 def data @data end |
Instance Method Details
#params ⇒ Object
36 37 38 |
# File 'lib/sitemap/configuration.rb', line 36 def params data[:params] end |
#reset ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/sitemap/configuration.rb', line 27 def reset self.data = { :params => Defaults::PARAMS.dup, :search => Defaults::SEARCH.dup, :query_batch_size => Defaults::QUERY_BATCH_SIZE, :max_urls => Defaults::MAX_URLS } end |
#search ⇒ Object
40 41 42 |
# File 'lib/sitemap/configuration.rb', line 40 def search data[:search] end |