Class: DPay::Payer

Inherits:
Object
  • Object
show all
Defined in:
lib/dpay/payment/payer.rb,
sig/dpay/payment/payer.rbs

Constant Summary collapse

EMAIL =

Returns:

  • (Regexp)
/\A[^@\s]+@[^@\s]+\.[^@\s]+\z/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailString? (readonly)

Returns the value of attribute email.

Returns:

  • (String, nil)


7
8
9
# File 'lib/dpay/payment/payer.rb', line 7

def email
  @email
end

#first_nameString? (readonly)

Returns the value of attribute first_name.

Returns:

  • (String, nil)


7
8
9
# File 'lib/dpay/payment/payer.rb', line 7

def first_name
  @first_name
end

#last_nameString? (readonly)

Returns the value of attribute last_name.

Returns:

  • (String, nil)


7
8
9
# File 'lib/dpay/payment/payer.rb', line 7

def last_name
  @last_name
end

Class Method Details

.createPayer

Returns:



9
10
11
# File 'lib/dpay/payment/payer.rb', line 9

def self.create
  new
end

Instance Method Details

#with_email(email) ⇒ self

Parameters:

  • email (String)

Returns:

  • (self)

Raises:



13
14
15
16
17
18
# File 'lib/dpay/payment/payer.rb', line 13

def with_email(email)
  raise InvalidArgumentError, %(Invalid email "#{email}") unless email.is_a?(String) && EMAIL.match?(email)

  @email = email
  self
end

#with_name(first_name, last_name) ⇒ self

Parameters:

  • first_name (String)
  • last_name (String)

Returns:

  • (self)


20
21
22
23
24
# File 'lib/dpay/payment/payer.rb', line 20

def with_name(first_name, last_name)
  @first_name = first_name
  @last_name = last_name
  self
end