Class: Osm::OnlinePayment::Schedule::PaymentStatus

Inherits:
Model
  • Object
show all
Defined in:
lib/osm/online_payment.rb,
lib/osm/online_payment.rb

Overview

Ensure the constant exists for validators

Constant Summary collapse

VALID_STATUSES =
[:required, :not_required, :initiated, :paid, :received, :paid_manually]

Constants inherited from Model

Model::SORT_BY

Instance Method Summary collapse

Methods inherited from Model

#<, #<=, #>, #>=, #between?, #changed_attributes, configure, #reset_changed_attributes, #to_i

Constructor Details

#initializeObject

Initialize a new PaymentStatus

Parameters:

  • attributes (Hash)

    The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)



# File 'lib/osm/online_payment.rb', line 445

Instance Method Details

#<=>(another) ⇒ Object



475
476
477
478
479
480
# File 'lib/osm/online_payment.rb', line 475

def <=>(another)
  result = -(self.timestamp <=> another.try(:timestamp))
  result = self.payment <=> another.try(:payment) if result.eql?(0)
  result = self.id <=> another.try(:id) if result.eql?(0)
  return result
end

#initiated?Boolean

Whether the status is :initiated

Returns:

  • (Boolean)


468
469
470
471
472
# File 'lib/osm/online_payment.rb', line 468

VALID_STATUSES.each do |attribute|
  define_method "#{attribute}?" do
    status.eql?(attribute)
  end
end

#inspectObject



482
483
484
# File 'lib/osm/online_payment.rb', line 482

def inspect
  Osm.inspect_instance(self, {:replace_with => {'payment' => :id}})
end

#not_required?Boolean

Whether the status is :not_required

Returns:

  • (Boolean)


468
469
470
471
472
# File 'lib/osm/online_payment.rb', line 468

VALID_STATUSES.each do |attribute|
  define_method "#{attribute}?" do
    status.eql?(attribute)
  end
end

#paid?Boolean

Whether the status is :paid

Returns:

  • (Boolean)


468
469
470
471
472
# File 'lib/osm/online_payment.rb', line 468

VALID_STATUSES.each do |attribute|
  define_method "#{attribute}?" do
    status.eql?(attribute)
  end
end

Whether the status is :paid_manually

Returns:

  • (Boolean)


468
469
470
471
472
# File 'lib/osm/online_payment.rb', line 468

VALID_STATUSES.each do |attribute|
  define_method "#{attribute}?" do
    status.eql?(attribute)
  end
end

#received?Boolean

Whether the status is :received

Returns:

  • (Boolean)


468
469
470
471
472
# File 'lib/osm/online_payment.rb', line 468

VALID_STATUSES.each do |attribute|
  define_method "#{attribute}?" do
    status.eql?(attribute)
  end
end

#required?Boolean

Whether the status is :required

Returns:

  • (Boolean)


468
469
470
471
472
# File 'lib/osm/online_payment.rb', line 468

VALID_STATUSES.each do |attribute|
  define_method "#{attribute}?" do
    status.eql?(attribute)
  end
end