Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

check for Hash by checking for to_hash

  • Loading branch information...
commit 2e976ae4763165b7f879512c17eca84b02282def 1 parent 0458dbc
Daniel Mendler authored September 23, 2012
2  lib/temple/mixins/engine_dsl.rb
@@ -96,7 +96,7 @@ def chain_name(name)
96 96
       end
97 97
 
98 98
       def chain_class_constructor(filter, option_filter)
99  
-        local_options = Hash === option_filter.last ? option_filter.pop : {}
  99
+        local_options = option_filter.last.respond_to?(:to_hash) ? option_filter.pop.to_hash : {}
100 100
         raise(ArgumentError, 'Only symbols allowed in option filter') unless option_filter.all? {|o| Symbol === o }
101 101
         define_options(*option_filter) if respond_to?(:define_options)
102 102
         proc do |engine|
8  lib/temple/mixins/options.rb
@@ -20,8 +20,8 @@ def default_options
20 20
       end
21 21
 
22 22
       def define_options(*opts)
23  
-        if opts.last.respond_to?(:keys)
24  
-          hash = opts.pop
  23
+        if opts.last.respond_to?(:to_hash)
  24
+          hash = opts.pop.to_hash
25 25
           default_options.add_valid_keys(hash.keys)
26 26
           default_options.update(hash)
27 27
         end
@@ -29,8 +29,8 @@ def define_options(*opts)
29 29
       end
30 30
 
31 31
       def define_deprecated_options(*opts)
32  
-        if opts.last.respond_to?(:keys)
33  
-          hash = opts.pop
  32
+        if opts.last.respond_to?(:to_hash)
  33
+          hash = opts.pop.to_hash
34 34
           default_options.add_deprecated_keys(hash.keys)
35 35
           default_options.update(hash)
36 36
         end

0 notes on commit 2e976ae

Please sign in to comment.
Something went wrong with that request. Please try again.