Module: GrapeClient::RestMethodsMember

Included in:
Base
Defined in:
lib/grape_client/rest_methods_member.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



28
29
30
31
# File 'lib/grape_client/rest_methods_member.rb', line 28

def destroy
  self.class.cache.remove(self)
  delete
end

#reloadObject



20
21
22
23
24
25
26
# File 'lib/grape_client/rest_methods_member.rb', line 20

def reload
  get(nil) do |response|
    ResponseParser.new(response, self).parse
  end
  self.class.cache.store(self)
  self
end

#saveObject



14
15
16
17
18
# File 'lib/grape_client/rest_methods_member.rb', line 14

def save
  save!
rescue Connection::InvalidEntity, Connection::UnknownError
  false
end

#save!Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/grape_client/rest_methods_member.rb', line 3

def save!
  if id.present?
    put(nil, to_post)
  else
    post(nil, to_post) do |response|
      ResponseParser.new(response, self).parse
    end
  end
  self.class.cache.store(self)
end