Module: Strobe::Resource::Collection

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary

Attributes included from Base

#response

Instance Method Summary collapse

Methods included from Base

#[], #[]=, #destroy, #initialize, #key?, #merge!, #params, #params=, #persisted?, #save, #save!

Methods included from Validations

#read_attribute_for_validation, #valid_attribute?, #valid_for_given_attributes?

Instance Method Details

#idObject

Raises:

  • (NotImplementedError)


105
106
107
# File 'lib/strobe/resource/collection.rb', line 105

def id
  raise NotImplementedError
end

#keyObject



109
110
111
# File 'lib/strobe/resource/collection.rb', line 109

def key
  self.class.key.key_for(self)
end

#reload(opts = {}) ⇒ Object



117
118
119
120
121
122
123
124
125
# File 'lib/strobe/resource/collection.rb', line 117

def reload(opts = {})
  resp = Strobe.connection.get self.class.resource_uri(key)
  resp.validate! if opts[:validate]

  if resp.success?
    self.params = self.class.denormalize_params(resp.body)
    self
  end
end

#reload!(opts = {}) ⇒ Object



113
114
115
# File 'lib/strobe/resource/collection.rb', line 113

def reload!(opts = {})
  reload(opts.merge(:validate => true))
end