Class: Locomotive::Coal::Resources::ContentTypes

Inherits:
Base
  • Object
show all
Defined in:
lib/locomotive/coal/resources/content_types.rb

Instance Attribute Summary

Attributes inherited from Base

#credentials, #uri

Instance Method Summary collapse

Methods inherited from Base

#create, #destroy, #destroy_all, #index, #initialize, #update, #update_with_locale

Methods included from Locomotive::Coal::Resources::Concerns::Request

#delete, #do_request, #get, #post, #put, #without_authentication

Constructor Details

This class inherits a constructor from Locomotive::Coal::Resources::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/locomotive/coal/resources/content_types.rb', line 13

def method_missing(meth, *args)
  if content_type = by_slug(meth)
    Locomotive::Coal::Resources::ContentEntries.new(uri, credentials, content_type)
  else
    super
  end
end

Instance Method Details

#by_slug(slug) ⇒ Object



6
7
8
9
10
11
# File 'lib/locomotive/coal/resources/content_types.rb', line 6

def by_slug(slug)
  get('content_types').each do |attributes|
    return Resource.new(attributes) if attributes['slug'].to_s == slug.to_s
  end
  nil
end