Class: Zedlocales::ContentScopes

Inherits:
Object
  • Object
show all
Defined in:
lib/zedlocales/content_scopes.rb

Class Method Summary collapse

Class Method Details

.content(*args) {|reshh| ... } ⇒ Object

Yields:

  • (reshh)


88
89
90
91
92
93
# File 'lib/zedlocales/content_scopes.rb', line 88

def content(*args)
  zopts = args.extract_zedkit_options!
  reshh = Zedkit::Client.get('content/content', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
  yield(reshh) if (not reshh.nil?) && block_given?
  reshh
end

.create(*args) {|reshh| ... } ⇒ Object

Yields:

  • (reshh)


66
67
68
69
70
71
# File 'lib/zedlocales/content_scopes.rb', line 66

def create(*args)
  zopts = args.extract_zedkit_options!
  reshh = Zedkit::Client.create('content/scopes', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
  yield(reshh) if (not reshh.nil?) && block_given?
  reshh
end

.delete(*args) {|reshh| ... } ⇒ Object

Yields:

  • (reshh)


81
82
83
84
85
86
# File 'lib/zedlocales/content_scopes.rb', line 81

def delete(*args)
  zopts = args.extract_zedkit_options!
  reshh = Zedkit::Client.delete("content/scopes/#{zopts[:uuid]}", zopts[:user_key])
  yield(reshh) if (not reshh.nil?) && block_given?
  reshh
end

.get(*args) {|reshh| ... } ⇒ Object

Zedlocales Content Scopes

All Zedkit applications have optional content. You can create, read, update, or delete content scopes within sections to organize it. To perform an operation on a specific content scope you need its UUID, as available from the ContentSections.scopes method.

To get a Content Scope:

Zedlocales::ContentScopes.get(:user_key => user['user_key'], :uuid => scope['uuid'])

To update a Content Scope:

Zedlocales::ContentScopes.update(:user_key => user['user_key'],
                                 :uuid => scope['uuid'], :scope => { :key => 'whatever' })

To delete a Content Scope:

Zedlocales::ContentScopes.delete(:user_key => user['user_key'], :uuid => scope['uuid'])

To create a new Content Scope you submit the required parameters with the section UUID that you are creating the content scope for. Whatever items you send within the :scope Hash are passed through to the ZedAPI untouched. There is no client side validation within this gem.

Zedlocales::ContentScopes.create(:user_key => user['user_key'],
                                 :section => { :uuid => section['uuid'] }, :scope => { :key => 'whatever' })

From each of these requests the Zedkit::Client class will return a response hash for your reference, if needed, or as applicable to the request. If there was a HTTP 401 or 404 you will get a nil response. This indicates a security failure or that an UUID is incorrect, not attached the user’s account, or non-existent.

For each request you can also pass a block to process the response directly:

Zedlocales::ContentSections.get(:user_key => user['user_key'], :uuid => scope['uuid']) do |result|
end

Yields:

  • (reshh)


58
59
60
61
62
63
64
# File 'lib/zedlocales/content_scopes.rb', line 58

def get(*args)
  zopts = args.extract_zedkit_options!
  reshh = Zedkit::Client.get("content/scopes/#{zopts[:uuid]}", zopts[:user_key],
                                         zopts.zdelete_keys!(%w(uuid user_key)))
  yield(reshh) if (not reshh.nil?) && block_given?
  reshh
end

.update(*args) {|reshh| ... } ⇒ Object

Yields:

  • (reshh)


73
74
75
76
77
78
79
# File 'lib/zedlocales/content_scopes.rb', line 73

def update(*args)
  zopts = args.extract_zedkit_options!
  reshh = Zedkit::Client.update("content/scopes/#{zopts[:uuid]}", zopts[:user_key],
                                            zopts.zdelete_keys!(%w(uuid user_key)))
  yield(reshh) if (not reshh.nil?) && block_given?
  reshh
end