Class: Amountable::Amount

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Operations
Defined in:
lib/amountable/amount.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Operations

#*, #+, #-, #/, #to_money

Instance Attribute Details

#persistableObject

Returns the value of attribute persistable.



28
29
30
# File 'lib/amountable/amount.rb', line 28

def persistable
  @persistable
end

Class Method Details

.column(name, sql_type = nil, default = nil, null = true) ⇒ Object



8
9
10
11
# File 'lib/amountable/amount.rb', line 8

def self.column(name, sql_type = nil, default = nil, null = true)
  type = "ActiveRecord::Type::#{sql_type.to_s.camelize}".constantize.new
  columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, type, null)
end

Instance Method Details

#saveObject

Raises:

  • (StandardError)


30
31
32
33
# File 'lib/amountable/amount.rb', line 30

def save
  raise StandardError.new("Can't persist amount to database") if persistable == false
  super
end