Class: Contentstack::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/contentstack/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs, content_type_uid = nil) ⇒ Entry

Returns a new instance of Entry.



4
5
6
# File 'lib/contentstack/entry.rb', line 4

def initialize(attrs, content_type_uid=nil)
  setup(attrs, content_type_uid)
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



3
4
5
# File 'lib/contentstack/entry.rb', line 3

def content_type
  @content_type
end

#fieldsObject (readonly)

Returns the value of attribute fields.



3
4
5
# File 'lib/contentstack/entry.rb', line 3

def fields
  @fields
end

#ownerObject (readonly)

Returns the value of attribute owner.



3
4
5
# File 'lib/contentstack/entry.rb', line 3

def owner
  @owner
end

#uidObject (readonly)

Returns the value of attribute uid.



3
4
5
# File 'lib/contentstack/entry.rb', line 3

def uid
  @uid
end

Instance Method Details

#fetchObject



8
9
10
11
12
# File 'lib/contentstack/entry.rb', line 8

def fetch
  entry = API.fetch_entry(@content_type, self.fields[:uid])
  setup(entry["entry"])
  self
end

#get(field_uid) ⇒ Object



14
15
16
17
# File 'lib/contentstack/entry.rb', line 14

def get(field_uid)
  raise Contentstack::Error("Please send a valid Field UID") if field_uid.class != String
  @fields[field_uid.to_sym]
end