class Kodmin::Consumer::HmacAuth

Consumer's HMAC credential.

Attributes

consumer[RW]
created_at[RW]
id[RW]
secret[RW]
username[RW]

Public Class Methods

new(attributes = {}) click to toggle source

New a HmacAuth. @param attributes [Hash] attributes of the HmacAuth.

# File lib/kodmin/consumers.rb, line 41
def initialize(attributes = {})
  from_hash(attributes)
end

Public Instance Methods

from_hash(attributes) click to toggle source

Assign attributes from a Hash object. @param attributes [Hash] hash representation of attributes.

# File lib/kodmin/consumers.rb, line 47
def from_hash(attributes)
  attributes.each_key do |key|
    if key.to_sym == :consumer
      self.consumer = Consumer.new(attributes[key])
    else
      setter = "#{key}=".to_sym
      send(setter, attributes[key]) if respond_to?(setter)
    end
  end
end
to_hash() click to toggle source
# File lib/kodmin/consumers.rb, line 58
def to_hash
  hash = {}
  hash[:id] = id unless id.nil?
  hash[:consumer] = consumer.to_hash unless consumer.nil?
  hash[:username] = username unless username.nil?
  hash[:secret] = secret unless secret.nil?
  hash[:created_at] = created_at unless created_at.nil?
  hash
end