Class: Journey::Resource

Inherits:
ActiveResource::Base
  • Object
show all
Includes:
API, Attachments, AttributeLoading, BatchWhere, Count, Embed, EnumSets, Enums, Queries, Search, WhereMultiple
Defined in:
lib/journey/resource.rb,
lib/journey/resource.rb

Direct Known Subclasses

Oplog

Defined Under Namespace

Modules: API, Attachments, AttributeLoading, BatchWhere, Count, Embed, EnumSets, Enums, Queries, Search, WhereMultiple

Class Method Summary collapse

Class Method Details

.find(*arguments) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/journey/resource.rb', line 4

def self.find(*arguments)
  scope   = arguments.slice!(0)

  options = arguments.slice!(0) || {}

  self.embeds ||= []

  if options.has_key?(:embed)
    embed_option = options.delete(:embed)
    options.deep_merge!(params: { embed: embed_option }) if embed_option
  else
    options.deep_merge!(params: { embed: embeds })
  end

  super *([scope, options] + arguments)
end

.where(clauses = {}) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/journey/resource.rb', line 21

def self.where(clauses={})
  raise ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash

  arguments = if clauses.has_key?(:embed)
    embed = clauses.delete(:embed)
    { params: clauses, embed: embed }        
  else
    { params: clauses }
  end

  find(:all, arguments)
end