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
#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
.all ⇒ Object
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 |
#fetch ⇒ Object
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 |