Module: StateFu::Applicable::InstanceMethods
- Defined in:
- lib/support/applicable.rb
Instance Method Summary collapse
-
#apply!(_options = nil, &block) ⇒ Object
if given a hash of options (or a splatted arglist containing one), merge them into @options.
Instance Method Details
#apply!(_options = nil, &block) ⇒ Object
if given a hash of options (or a splatted arglist containing one), merge them into @options. If given a block, eval it (yielding self if the block expects it)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/support/applicable.rb', line 9 def apply!( =nil, &block ) if .is_a?(Array) = .dup..symbolize_keys else ||= {} = .symbolize_keys! end @options = @options.nil?? : @options.merge() returning self do if block_given? case block.arity.abs when 1, -1 instance_exec self, &block when 0 instance_exec &block else raise ArgumentError, "Your block wants too many arguments!" end end end end |