class Kongfigure::Resources::Consumer

Attributes

acls[RW]
custom_id[RW]
key_auths[RW]
username[RW]

Public Class Methods

build(hash) click to toggle source
# 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

Public Instance Methods

api_attributes() click to toggle source
# File lib/kongfigure/resources/consumer.rb, line 25
def api_attributes
  {
    "username"  =>  username,
    "custom_id" => custom_id
  }.compact
end
api_name() click to toggle source
# File lib/kongfigure/resources/consumer.rb, line 21
def api_name
  "consumers"
end
has_acl?(acl) click to toggle source
# File lib/kongfigure/resources/consumer.rb, line 36
def has_acl?(acl)
  acls && acls.include?(acl)
end
has_key_auth?(key_auth) click to toggle source
# File lib/kongfigure/resources/consumer.rb, line 32
def has_key_auth?(key_auth)
  key_auths && key_auths.include?(key_auth)
end
identifier() click to toggle source
# File lib/kongfigure/resources/consumer.rb, line 17
def identifier
  username
end
to_s() click to toggle source
# File lib/kongfigure/resources/consumer.rb, line 40
def to_s
  "#{username}"
end