def attr_search(*attributes)  
      options       = attributes.last.is_a?(Hash) ? attributes.pop : {}
      type          = (options.fetch(:type) { :simple }).to_sym
      accepted_keys = [:simple] + self.reflections.keys.map(&:to_sym)
      
      unless accepted_keys.include?(type.to_sym)
        raise ArgumentError, 'incorect type given'
      end

      search_attributes_hash!(attributes, type, search_attributes)
    end
def attr_search(*attributes)  
      options       = attributes.last.is_a?(Hash) ? attributes.pop : {}
      type          = (options.fetch(:type) { :simple }).to_sym
      accepted_keys = [:simple] + self.reflections.keys.map(&:to_sym)
      
      unless accepted_keys.include?(type.to_sym)
        raise ArgumentError, 'incorect type given'
      end

      search_attributes_hash!(attributes, type, search_attributes)
    end
assuming the last attribute could be a hash