6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/i18n_konjac/acts_as_konjac.rb', line 6
def acts_as_konjac(*args)
include I18nKonjac::ActsAsKonjac::LocalInstanceMethods
return unless ActiveRecord::Base.connection.data_source_exists? self.to_s.pluralize.underscore
attrs = self.column_names
attrs = attrs + args if args.present?
attrs.each do |attr|
define_method "#{attr}_by_locale" do
val = if self.attribute_present?("#{current_prefix}#{attr}")
self.send("#{current_prefix}#{attr}")
end
val.presence || self.send("#{attr}")
end
end
end
|