Class: GuardianContent::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/guardian-content.rb

Direct Known Subclasses

Content, Section, Tag

Instance Method Summary collapse

Constructor Details

#initialize(key = nil) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
# File 'lib/guardian-content.rb', line 14

def initialize(key = nil)
  if defined?(GUARDIAN_CONTENT_API_KEY)
    key = GUARDIAN_CONTENT_API_KEY
  end
  self.class.default_params "api-key" => key, "format" => "json"
end

Instance Method Details

#reload(options = nil) ⇒ Object



21
22
23
24
# File 'lib/guardian-content.rb', line 21

def reload(options = nil)
  @attributes.update(self.class.find_by_id(self.id, options).instance_variable_get('@attributes'))
  self
end