Class: Interage::ApplicationBuilder

Inherits:
Request::Builder show all
Defined in:
lib/interage/application_builder.rb

Direct Known Subclasses

ApplicationBuilder

Instance Attribute Summary

Attributes inherited from Request::Builder

#created_at, #id, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request::Builder

#initialize, #persisted?

Constructor Details

This class inherits a constructor from Interage::Request::Builder

Class Method Details

.all(*args) ⇒ Object



9
10
11
# File 'lib/interage/application_builder.rb', line 9

def self.all(*args)
  new.requester.all(*args)
end

.find(*args) ⇒ Object



13
14
15
# File 'lib/interage/application_builder.rb', line 13

def self.find(*args)
  new.requester.find(*args)
end

.paginate(*args) ⇒ Object



5
6
7
# File 'lib/interage/application_builder.rb', line 5

def self.paginate(*args)
  new.requester.paginate(*args)
end

Instance Method Details

#create(params = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/interage/application_builder.rb', line 17

def create(params = {})
  self.attributes = params

  return false if invalid?

  response = requester.create(changeable_attributes)

  mount_errors(response.errors)

  response.success?
end

#destroyObject



41
42
43
44
45
46
47
# File 'lib/interage/application_builder.rb', line 41

def destroy
  response = requester.destroy(id)

  mount_errors(response.errors)

  response.success?
end

#requesterObject

Raises:

  • (ArgumentError)


49
50
51
52
# File 'lib/interage/application_builder.rb', line 49

def requester
  raise ArgumentError,
        "requester is missing for #{self.class.superclass.name}"
end

#update(params = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/interage/application_builder.rb', line 29

def update(params = {})
  self.attributes = params

  return false if invalid?

  response = requester.update(id, changeable_attributes)

  mount_errors(response.errors)

  response.success?
end