Class: StorageRoom::Entry
- Defined in:
- lib/storage_room/models/entry.rb
Instance Attribute Summary
Attributes inherited from Model
Class Method Summary collapse
-
.find_by_ids(*ids) ⇒ Object
Find multiple Entries by their IDs with one query.
-
.find_by_urls(*urls) ⇒ Object
Find multiple Entries by their URLs with one query.
-
.index_path ⇒ Object
:nodoc:.
-
.json_name ⇒ Object
:nodoc:.
-
.search(parameters = {}) ⇒ Object
Search for objects with specific parameters.
-
.search_path(parameters = {}) ⇒ Object
:nodoc:.
-
.show_path(entry_id) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#collection ⇒ Object
The collection of a entry.
- #id ⇒ Object
-
#trashed? ⇒ Boolean
Has this Entry been trashed?.
Methods inherited from Model
all, create, #create, #destroy, #errors, find, #initialize, #new_record?, #reset!, #save, #to_hash, #update, #valid?
Methods inherited from Resource
handle_critical_response_errors, #loaded?, meta_data?, #reload
Methods included from Plugins
Methods included from Accessors
#[], #as_json, #attributes, #attributes=, #eql?, #hash, #initialize, #inspect, #loaded?, #proxy?, #reset!, #response_data, #response_data=, #set_from_response_data, #to_hash
Constructor Details
This class inherits a constructor from StorageRoom::Model
Class Method Details
.find_by_ids(*ids) ⇒ Object
Find multiple Entries by their IDs with one query
30 31 32 |
# File 'lib/storage_room/models/entry.rb', line 30 def find_by_ids(*ids) find_by_urls(*ids.map{|id| show_path(id)}) end |
.find_by_urls(*urls) ⇒ Object
Find multiple Entries by their URLs with one query
35 36 37 |
# File 'lib/storage_room/models/entry.rb', line 35 def find_by_urls(*urls) search(:@url.in => urls) end |
.index_path ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/storage_room/models/entry.rb', line 8 def index_path # :nodoc: "#{collection[:@url]}/entries" end |
.json_name ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/storage_room/models/entry.rb', line 16 def json_name # :nodoc: 'entry' end |
.search(parameters = {}) ⇒ Object
Search for objects with specific parameters
25 26 27 |
# File 'lib/storage_room/models/entry.rb', line 25 def search(parameters = {}) Array.load(search_path(parameters)) end |
.search_path(parameters = {}) ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/storage_room/models/entry.rb', line 20 def search_path(parameters = {}) # :nodoc: parameters.present? ? "#{index_path}?#{parameters.to_query}" : index_path end |
.show_path(entry_id) ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/storage_room/models/entry.rb', line 12 def show_path(entry_id) # :nodoc: "#{index_path}/#{entry_id}" end |
Instance Method Details
#collection ⇒ Object
The collection of a entry
42 43 44 |
# File 'lib/storage_room/models/entry.rb', line 42 def collection self.class.collection end |
#id ⇒ Object
51 52 53 |
# File 'lib/storage_room/models/entry.rb', line 51 def id self[:@url] ? self[:@url].split('/').last : nil end |
#trashed? ⇒ Boolean
Has this Entry been trashed?
47 48 49 |
# File 'lib/storage_room/models/entry.rb', line 47 def trashed? self[:@trash] end |