lib/buttercms/content.rb in buttercms-ruby-1.0.8 vs lib/buttercms/content.rb in buttercms-ruby-1.0.9

- old
+ new

@@ -1,7 +1,21 @@ module ButterCMS class Content + attr_reader :data + + def initialize(json) + @json = json + @data = HashToObject.convert(json["data"]) + end + + 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 + def self.fetch(keys = []) - ButterCMS.request("/content", {keys: keys.join(',')}) + response = ButterCMS.request("/content", {keys: keys.join(',')}) + + self.new(response) end end end \ No newline at end of file