Class: WithoutScope::ActsAsRevisable::Options
- Inherits:
-
Object
- Object
- WithoutScope::ActsAsRevisable::Options
- Defined in:
- lib/acts_as_revisable/options.rb
Overview
This class provides for a flexible method of setting options and querying them. This is especially useful for giving users flexibility when using your plugin.
Instance Method Summary collapse
-
#initialize(*options, &block) ⇒ Options
constructor
A new instance of Options.
- #method_missing(key, *args) ⇒ Object
Constructor Details
#initialize(*options, &block) ⇒ Options
Returns a new instance of Options.
7 8 9 10 |
# File 'lib/acts_as_revisable/options.rb', line 7 def initialize(*, &block) @options = . instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/acts_as_revisable/options.rb', line 12 def method_missing(key, *args) return (@options[key.to_s.gsub(/\?$/, '').to_sym].eql?(true)) if key.to_s.match(/\?$/) if args.blank? @options[key.to_sym] else @options[key.to_sym] = args.size == 1 ? args.first : args end end |