Class: SkullIsland::Resources::BasicauthCredential
- Inherits:
-
SkullIsland::Resource
- Object
- SkullIsland::Resource
- SkullIsland::Resources::BasicauthCredential
- Defined in:
- lib/skull_island/resources/basicauth_credential.rb
Overview
The BasicauthCredential resource class
Instance Attribute Summary
Attributes inherited from SkullIsland::Resource
Class Method Summary collapse
Instance Method Summary collapse
-
#consumer ⇒ Object
The consumer property.
-
#created_at ⇒ Object
The created_at property.
- #export(options = {}) ⇒ Object
-
#modified_existing? ⇒ Boolean
Keys can’t be updated, only created or deleted.
-
#password ⇒ Object
The password property.
- #relative_uri ⇒ Object
- #save_uri ⇒ Object
-
#username ⇒ Object
The username property.
Methods inherited from SkullIsland::Resource
all, find, from_hash, gen_getter_method, gen_property_methods, gen_setter_method, get, immutable, #initialize, property, where
Methods included from Helpers::ResourceClass
#determine_getter_names, #determine_setter_names, #human, #i18n_key, #immutable?, #param_key, #properties, #route_key
Methods included from Helpers::Resource
#<=>, #datetime_from_params, #delayed_set, #destroy, #digest, #digest_properties, #find_by_digest, #fresh?, #host_regex, #id, #id_property, #immutable?, #import_update_or_skip, #lookup, #model_name, #new?, #persisted?, #postprocess_created_at, #postprocess_updated_at, #properties, #prune_for_save, #reload, #required_properties, #save, #tainted?, #to_param, #to_s, #update
Methods included from Validations::Resource
#validate_id, #validate_mutability, #validate_required_properties, #validate_tags
Constructor Details
This class inherits a constructor from SkullIsland::Resource
Class Method Details
.batch_import(data, verbose: false, test: false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 18 def self.batch_import(data, verbose: false, test: false) raise(Exceptions::InvalidArguments) unless data.is_a?(Array) data.each_with_index do |resource_data, index| resource = new resource.username = resource_data['username'] resource.password = resource_data['password'] if resource_data['password'] resource.delayed_set(:consumer, resource_data, 'consumer') resource.import_update_or_skip(index: index, verbose: verbose, test: test) end end |
.relative_uri ⇒ Object
30 31 32 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 30 def self.relative_uri 'basic-auths' end |
Instance Method Details
#consumer ⇒ Object
The consumer property
12 13 14 15 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 12 property( :consumer, required: true, validate: true, preprocess: true, postprocess: true ) |
#created_at ⇒ Object
The created_at property
16 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 16 property :created_at, read_only: true, postprocess: true |
#export(options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 42 def export( = {}) hash = { 'username' => username, 'password' => password } hash['consumer'] = "<%= lookup :consumer, '#{consumer.username}' %>" if consumer [*[:exclude]].each do |exclude| hash.delete(exclude.to_s) end [*[:include]].each do |inc| hash[inc.to_s] = send(inc.to_sym) end hash.reject { |_, value| value.nil? } end |
#modified_existing? ⇒ Boolean
Keys can’t be updated, only created or deleted
55 56 57 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 55 def modified_existing? false end |
#password ⇒ Object
The password property
11 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 11 property :password, validated: true |
#relative_uri ⇒ Object
34 35 36 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 34 def relative_uri consumer ? "#{consumer.relative_uri}/basic-auth/#{id}" : nil end |
#save_uri ⇒ Object
38 39 40 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 38 def save_uri consumer ? "#{consumer.relative_uri}/basic-auth" : nil end |
#username ⇒ Object
The username property
10 |
# File 'lib/skull_island/resources/basicauth_credential.rb', line 10 property :username, required: true, validate: true |