Class: Contentstack::ContentType

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ContentType

Returns a new instance of ContentType.



27
28
29
# File 'lib/contentstack/content_type.rb', line 27

def initialize(object)
  @attributes = object.symbolize_keys
end

Class Method Details

.allObject



40
41
42
43
44
45
# File 'lib/contentstack/content_type.rb', line 40

def self.all
  content_types = API.fetch_content_types["content_types"]
  content_types.map do |content_type|
    ContentType.new(content_type.inject({}){|clone,(k,v)| clone[k.to_sym] = v; clone})
  end
end

.find_by_uid(uid) ⇒ Object



47
48
49
50
# File 'lib/contentstack/content_type.rb', line 47

def self.find_by_uid(uid)
  content_type = API.fetch_content_types(uid)["content_type"]
  ContentType.new(content_type.inject({}){|clone,(k,v)| clone[k.to_sym] = v; clone})
end

Instance Method Details

#entry(entry_uid) ⇒ Object



35
36
37
# File 'lib/contentstack/content_type.rb', line 35

def entry(entry_uid)
  Entry.new({uid: entry_uid}, self.uid)
end

#queryObject



31
32
33
# File 'lib/contentstack/content_type.rb', line 31

def query
  Query.new(self.uid)
end