Class: ZedDB::ModelValidations

Inherits:
Object
  • Object
show all
Defined in:
lib/zeddb/resources/model_validations.rb

Class Method Summary collapse

Class Method Details

.create(zks = {}, &block) ⇒ Object



53
54
55
# File 'lib/zeddb/resources/model_validations.rb', line 53

def create(zks = {}, &block)
  Zedkit::Client.crud(:create, "db/items/#{zks[:item][:uuid]}/validations", zks, %w(item), &block)
end

.delete(zks = {}, &block) ⇒ Object



61
62
63
# File 'lib/zeddb/resources/model_validations.rb', line 61

def delete(zks = {}, &block)
  Zedkit::Client.crud(:delete, "db/items/#{zks[:item][:uuid]}/validations/#{zks[:uuid]}", zks, [], &block)
end

.get(zks = {}, &block) ⇒ Object

ZedDB Model Validations

ZedDB model data items can have standard validations attached to them. You can create, update (if applicable to the validation type) or delete model item validations. A model item’s validations are listed within its API response data set.

To create a new model item validation you submit the required parameters of the validation type with the model item UUID that you are attaching a valiation to. Whatever items you send within the :validation Hash are passed through to the ZedAPI untouched. There is no client side validation within this gem.

ZedDB::ModelValidations.create(:user_key => user['user_key'], :item => { :uuid => item['uuid'] },
                               :validation => { :code => "SB" })

To delete a model item validation:

ZedDB::ModelValidations.delete(:user_key => user['user_key'], :uuid => validation['uuid])

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:

ZedDB::ModelValidations.delete(:user_key => user['user_key'], :uuid => validation['uuid]) do |result|
end


49
50
51
# File 'lib/zeddb/resources/model_validations.rb', line 49

def get(zks = {}, &block)
  Zedkit::Client.crud(:get, "db/items/#{zks[:item][:uuid]}/validations/#{zks[:uuid]}", zks, %w(item), &block)
end

.update(zks = {}, &block) ⇒ Object



57
58
59
# File 'lib/zeddb/resources/model_validations.rb', line 57

def update(zks = {}, &block)
  Zedkit::Client.crud(:update, "db/items/#{zks[:item][:uuid]}/validations/#{zks[:uuid]}", zks, %w(item), &block)
end