Sha256: b7b95188eee31862545dbcd48f6a92e062172289ac1b3ba552bb143c0bea3482

Contents?: true

Size: 866 Bytes

Versions: 4

Compression:

Stored size: 866 Bytes

Contents

module Paymill
  class Base
    include Paymill::Operations::All
    include Paymill::Operations::Create
    include Paymill::Operations::Find

    attr_accessor :created_at, :updated_at

    # Initializes the object using the given attributes
    #
    # @param [Hash] attributes The attributes to use for initialization
    def initialize(attributes = {})
      set_attributes(attributes)
      parse_timestamps
    end

    # Sets the attributes
    #
    # @param [Hash] attributes The attributes to initialize
    def set_attributes(attributes)
      attributes.each_pair do |key, value|
        instance_variable_set("@#{key}", value)
      end
    end

    # Parses UNIX timestamps and creates Time objects.
    def parse_timestamps
      @created_at = Time.at(created_at) if created_at
      @updated_at = Time.at(updated_at) if updated_at
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paymill-0.5.1 lib/paymill/base.rb
paymill-0.5.0 lib/paymill/base.rb
paymill-0.4.0 lib/paymill/base.rb
paymill-0.3.0 lib/paymill/base.rb