Class: Contentstack::ContentType
- Inherits:
-
Object
- Object
- Contentstack::ContentType
- Defined in:
- lib/contentstack/content_type.rb
Class Method Summary collapse
Instance Method Summary collapse
- #entry(entry_uid) ⇒ Object
- #fetch ⇒ Object
-
#initialize(object) ⇒ ContentType
constructor
A new instance of ContentType.
- #query ⇒ Object
Constructor Details
permalink #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
permalink .all ⇒ Object
[View source]
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
permalink #entry(entry_uid) ⇒ Object
[View source]
37 38 39 |
# File 'lib/contentstack/content_type.rb', line 37 def entry(entry_uid) Entry.new({uid: entry_uid}, self.uid) end |
permalink #fetch ⇒ Object
[View source]
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 |
permalink #query ⇒ Object
[View source]
33 34 35 |
# File 'lib/contentstack/content_type.rb', line 33 def query Query.new(self.uid) end |