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.



29
30
31
# File 'lib/contentstack/content_type.rb', line 29

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

Class Method Details

.allObject



42
43
44
45
46
47
# File 'lib/contentstack/content_type.rb', line 42

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

Instance Method Details

#entry(entry_uid) ⇒ Object



37
38
39
# File 'lib/contentstack/content_type.rb', line 37

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

#fetchObject



49
50
51
52
# File 'lib/contentstack/content_type.rb', line 49

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

#queryObject



33
34
35
# File 'lib/contentstack/content_type.rb', line 33

def query
  Query.new(self.uid)
end