Class: ActiveRecord::Base
Overview
See Currency::ActiveRecord::ClassMethods
Constant Summary collapse
- @@money_attributes =
{ }
Class Method Summary collapse
-
.each_money_attribute(&blk) ⇒ Object
Iterates through all known money attributes in all classes.
-
.money_attributes_for_class(cls) ⇒ Object
Returns an array of option hashes for all the money attributes of this class.
-
.register_money_attribute(attr_opts) ⇒ Object
Called by money macro when a money attribute is created.
Class Method Details
.each_money_attribute(&blk) ⇒ Object
Iterates through all known money attributes in all classes.
each_money_attribute { | money_opts |
...
}
31 32 33 34 35 36 37 |
# File 'lib/currency/active_record.rb', line 31 def self.each_money_attribute(&blk) @@money_attributes.each do | cls, hash | hash.each do | attr_name, attr_opts | yield attr_opts end end end |
.money_attributes_for_class(cls) ⇒ Object
Returns an array of option hashes for all the money attributes of this class.
Superclass attributes are not included.
21 22 23 |
# File 'lib/currency/active_record.rb', line 21 def self.money_attributes_for_class(cls) (@@money_atttributes[cls] || { }).values end |
.register_money_attribute(attr_opts) ⇒ Object
Called by money macro when a money attribute is created.
13 14 15 |
# File 'lib/currency/active_record.rb', line 13 def self.register_money_attribute(attr_opts) (@@money_attributes[attr_opts[:class]] ||= { })[attr_opts[:attr_name]] = attr_opts end |