Class: Paymill::Base

Inherits:
Object
  • Object
show all
Includes:
Operations::All, Operations::Create, Operations::Find
Defined in:
lib/paymill/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Operations::Find

included

Methods included from Operations::Create

included

Methods included from Operations::All

included

Constructor Details

#initialize(attributes = {}) ⇒ Base

Initializes the object using the given attributes

Parameters:

  • attributes (Hash) (defaults to: {})

    The attributes to use for initialization



12
13
14
15
# File 'lib/paymill/base.rb', line 12

def initialize(attributes = {})
  set_attributes(attributes)
  parse_timestamps
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



7
8
9
# File 'lib/paymill/base.rb', line 7

def created_at
  @created_at
end

#updated_atObject

Returns the value of attribute updated_at.



7
8
9
# File 'lib/paymill/base.rb', line 7

def updated_at
  @updated_at
end

Instance Method Details

#parse_timestampsObject

Parses UNIX timestamps and creates Time objects.



27
28
29
30
# File 'lib/paymill/base.rb', line 27

def parse_timestamps
  @created_at = Time.at(created_at) if created_at
  @updated_at = Time.at(updated_at) if updated_at
end

#set_attributes(attributes) ⇒ Object

Sets the attributes

Parameters:

  • attributes (Hash)

    The attributes to initialize



20
21
22
23
24
# File 'lib/paymill/base.rb', line 20

def set_attributes(attributes)
  attributes.each_pair do |key, value|
    instance_variable_set("@#{key}", value)
  end
end