Module: SmsOnRails::ActsAsSubstitutable::ClassMethods

Defined in:
lib/sms_on_rails/activerecord_extensions/acts_as_substitutable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_substitutable(method, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sms_on_rails/activerecord_extensions/acts_as_substitutable.rb', line 12

def acts_as_substitutable(method, options={})
  
  defaults =  {:time => Proc.new {|rec| Time.now.to_s(:db) }}

  class_eval do
    acts_as_sub_options[method.to_sym] = defaults.merge(options||{})
    def clear_substituted_params
      acts_as_sub_options.keys.each{|method| instance_variable_set("@#{method}", nil)}
    end
  end

  acts_as_substitutable_instance_methods(method)
end