Class: ButterCMS::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/buttercms/content.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Content

Returns a new instance of Content.



5
6
7
8
# File 'lib/buttercms/content.rb', line 5

def initialize(json)
  @json = json
  @data = HashToObject.convert(json["data"])
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/buttercms/content.rb', line 3

def data
  @data
end

Class Method Details

.fetch(keys = [], options = {}) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/buttercms/content.rb', line 15

def self.fetch(keys = [], options = {})
  params = {keys: keys.join(',')}.merge(options)

  response = ButterCMS.request("/content/", params)

  self.new(response)
end

Instance Method Details

#inspectObject



10
11
12
13
# File 'lib/buttercms/content.rb', line 10

def inspect
  id_string = (self.respond_to?(:id) && !self.id.nil?) ? " id=#{self.id}" : ""
  "#<#{self.class}:0x#{self.object_id.to_s(16)}#{id_string}> JSON: " + JSON.pretty_generate(@json)
end