Module: SmartCurrency::ClassMethods

Defined in:
lib/smart_currency.rb

Instance Method Summary collapse

Instance Method Details

#smart_currencyObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/smart_currency.rb', line 9

def smart_currency
  unless smart_currency?
      include InstanceMethods
      auto_attributes = []
      self.skip_time_zone_conversion_for_attributes = []
      attributes = self.columns.select {|c| (c.type == :integer || c.type == :decimal) && !c.name.match("id") }
      
      attributes.each do |a|
        define_method("#{a.name}=") do |val|
          self[a.name.to_sym] = currency_to_db(val)
        end  
      end  
      
  end    
end

#smart_currency?Boolean

Returns:



25
26
27
# File 'lib/smart_currency.rb', line 25

def smart_currency?
  self.included_modules.include?(InstanceMethods)
end