Class: Kongfigure::Resources::Consumer
- Defined in:
- lib/kongfigure/resources/consumer.rb
Instance Attribute Summary collapse
-
#acls ⇒ Object
Returns the value of attribute acls.
-
#custom_id ⇒ Object
Returns the value of attribute custom_id.
-
#key_auths ⇒ Object
Returns the value of attribute key_auths.
-
#username ⇒ Object
Returns the value of attribute username.
Attributes inherited from Base
#id, #kongfigure_ignore_fields, #plugins, #unchanged, #updated
Class Method Summary collapse
Instance Method Summary collapse
- #api_attributes ⇒ Object
- #api_name ⇒ Object
- #has_acl?(acl) ⇒ Boolean
- #has_key_auth?(key_auth) ⇒ Boolean
- #identifier ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
#==, build_all, #display_name, #has_to_be_deleted?, #initialize, #mark_as_unchanged, #mark_as_updated, #plugin_allowed?
Constructor Details
This class inherits a constructor from Kongfigure::Resources::Base
Instance Attribute Details
#acls ⇒ Object
Returns the value of attribute acls.
3 4 5 |
# File 'lib/kongfigure/resources/consumer.rb', line 3 def acls @acls end |
#custom_id ⇒ Object
Returns the value of attribute custom_id.
3 4 5 |
# File 'lib/kongfigure/resources/consumer.rb', line 3 def custom_id @custom_id end |
#key_auths ⇒ Object
Returns the value of attribute key_auths.
3 4 5 |
# File 'lib/kongfigure/resources/consumer.rb', line 3 def key_auths @key_auths end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/kongfigure/resources/consumer.rb', line 3 def username @username end |
Class Method Details
.build(hash) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/kongfigure/resources/consumer.rb', line 5 def self.build(hash) consumer = new(hash["id"], hash["kongfigure_ignore_fields"]) consumer.username = hash["username"] consumer.custom_id = hash["custom_id"] consumer.acls = Kongfigure::Resources::Consumers::ACL.build_all(hash["acls"] || []) consumer.plugins = Kongfigure::Resources::Plugin.build_all(hash["plugins"] || []) consumer.key_auths = (hash["key_auths"] || []).map do |key_auth_hash| Kongfigure::Resources::Consumers::KeyAuth.build(key_auth_hash) end consumer end |
Instance Method Details
#api_attributes ⇒ Object
25 26 27 28 29 30 |
# File 'lib/kongfigure/resources/consumer.rb', line 25 def api_attributes { "username" => username, "custom_id" => custom_id }.compact end |
#api_name ⇒ Object
21 22 23 |
# File 'lib/kongfigure/resources/consumer.rb', line 21 def api_name "consumers" end |
#has_acl?(acl) ⇒ Boolean
36 37 38 |
# File 'lib/kongfigure/resources/consumer.rb', line 36 def has_acl?(acl) acls && acls.include?(acl) end |
#has_key_auth?(key_auth) ⇒ Boolean
32 33 34 |
# File 'lib/kongfigure/resources/consumer.rb', line 32 def has_key_auth?(key_auth) key_auths && key_auths.include?(key_auth) end |
#identifier ⇒ Object
17 18 19 |
# File 'lib/kongfigure/resources/consumer.rb', line 17 def identifier username end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/kongfigure/resources/consumer.rb', line 40 def to_s "#{username}" end |