Module: Vodka::Her::Extensions::ExtendedOrm::ClassMethods

Defined in:
lib/vodka/her/extensions/extended_orm.rb

Instance Method Summary collapse

Instance Method Details

#all(params = {}) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/vodka/her/extensions/extended_orm.rb', line 40

def all(params = {})
  unless @where_conditions.nil?
    params[:vodka_special_where] = MultiJson.dump(@where_conditions)
    @where_conditions = nil
  end
  super(params)
end

#create!(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/vodka/her/extensions/extended_orm.rb', line 8

def create!(*args)
  resource = create(*args)
  unless resource.errors.empty?
    error = [resource.errors.keys.first, resource.errors.values.first].join(' ')
    raise Vodka::Client::ResourceException.new(error)
  end

  resource
end

#firstObject



18
19
20
21
22
23
24
# File 'lib/vodka/her/extensions/extended_orm.rb', line 18

def first
  resources = all(vodka_special_action: 'first')
  resource = resources.first
  resource.errors = resources.errors
  resource. = resources.
  resource
end

#lastObject



26
27
28
29
30
31
32
# File 'lib/vodka/her/extensions/extended_orm.rb', line 26

def last
  resources = all(vodka_special_action: 'last')
  resource = resources.first
  resource.errors = resources.errors
  resource. = resources.
  resource
end

#where(*args) ⇒ Object



34
35
36
37
38
# File 'lib/vodka/her/extensions/extended_orm.rb', line 34

def where(*args)
  @where_conditions ||= []
  @where_conditions << args
  self
end