diff --git a/lib/queryable_array.rb b/lib/queryable_array.rb index 606d0a9..b68cc4e 100644 --- a/lib/queryable_array.rb +++ b/lib/queryable_array.rb @@ -1,7 +1,6 @@ require 'respond_to_missing' require 'queryable_array/dot_notation' require 'queryable_array/dynamic_finder' -require 'queryable_array/queryable' require 'queryable_array/shorthand' require 'queryable_array/version' @@ -10,7 +9,6 @@ # overrides +[]+, +find_all+ and +method_missing+ to provide a simplified DSL # for looking up objects by querying their attributes. class QueryableArray < Array - include Queryable include Shorthand include DotNotation include DynamicFinder diff --git a/lib/queryable_array/default_finder.rb b/lib/queryable_array/default_finder.rb index 35ac83e..abdce70 100644 --- a/lib/queryable_array/default_finder.rb +++ b/lib/queryable_array/default_finder.rb @@ -1,3 +1,5 @@ +require 'queryable_array/queryable' + class QueryableArray < Array # Allows objects to be searched by +default_finders+ thru []. For example: # @@ -5,6 +7,10 @@ class QueryableArray < Array # users['test@example.com'] # => # # users['missing@domain.com'] # => nil module DefaultFinder + def self.included(base) + base.send :include, Queryable + end + attr_accessor :default_finders # Accepts an initial +array+ which defaults to +[]+. An optional +default_finders+