Class: Editmode::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/editmode/chunk.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChunk

Returns a new instance of Chunk.



2
3
# File 'lib/editmode/chunk.rb', line 2

def initialize
end

Class Method Details

.retrieve(project_id = Editmode.project_id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/editmode/chunk.rb', line 6

def retrieve(project_id = Editmode.project_id, options = {})
  begin
    root_url = Editmode.api_root_url
    chunk_id = options[:identifier] || options[:content_key]

    url = "#{root_url}/chunks/#{chunk_id}?project_id=#{project_id}"
    response = HTTParty.get(url)

    if chunk_id.present?
      return response
    else
      chunks = response.try(:[], "chunks")
      chunks ||= []
    end
  rescue => er
    Rails.logger.info er
    []
  end
end