Class: TheCity::Tag

Inherits:
ApiObject show all
Defined in:
lib/api/tag.rb

Instance Attribute Summary

Attributes inherited from ApiObject

#error_messages, #marked_for_destruction

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiObject

__tc_attributes, #delete, #initialize_from_json_object, #is_deleted?, #save, #set_attributes, tc_attr_accessor, #to_attributes

Constructor Details

#initialize(json_data = nil) ⇒ Tag

Constructor.

Parameters:

  • json_data (optional) (defaults to: nil)

    JSON data of the Tag.



25
26
27
28
# File 'lib/api/tag.rb', line 25

def initialize(json_data = nil)
  @writer_object = TagWriter
  initialize_from_json_object(json_data) unless json_data.nil?
end

Class Method Details

.load_by_id(tag_id) ⇒ Object

Loads the tag by the specified ID.

Returns a new TheCity::Tag object.

Parameters:

  • tag_id

    The ID of the tag to load.



15
16
17
18
19
20
# File 'lib/api/tag.rb', line 15

def self.load_by_id(tag_id)
  reader = TagReader.new(tag_id)
  self.new(reader.load_feed)
rescue
  nil
end