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
24
25
26
# File 'lib/smart_currency.rb', line 9

def smart_currency
  if !smart_currency? && table_exists?
      include InstanceMethods
      auto_attributes = []
      self.skip_time_zone_conversion_for_attributes = []
      
      self.send(:attr_accessor, :disable_smart_currency)
      
      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] = (disable_smart_currency == true ? val : currency_to_db(val))
        end  
      end  
      
  end    
end

#smart_currency?Boolean

Returns:



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

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