Skip to content
Browse files

cleanup

  • Loading branch information...
1 parent 4197b2a commit 8ad0000004b53a2d9ab73555114d7e6f7ce51de9 @dalpo committed May 17, 2011
View
2 has_foreign_language.gemspec
@@ -17,5 +17,5 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
- s.require_paths = [".","lib"]
+ s.require_paths = [".","lib", "rails"]
end
View
5 init.rb
@@ -1,5 +0,0 @@
-# Include hook code here
-require 'has_foreign_language'
-require 'form_fix'
-ActiveRecord::Base.send(:include, HasForeignLanguage)
-#ActionView::Helpers::FormHelper.send(:extend, FormFix)
View
44 lib/has_foreign_language.rb
@@ -1,40 +1,4 @@
-# HasForeignLanguage
-module HasForeignLanguage
- def self.included(mod)
- mod.extend(ClassMethods)
- end
-
- module ClassMethods
-
- def has_foreign_language(*args)
- args.each do |field|
-
- # Define the marker
- eigenclass = class << self
- self
- end
- eigenclass.class_eval do
- define_method("has_foreign_language_#{field.to_s}?") { true }
- end
-
- # Define the getter
- define_method(field.to_s) do
- if self.class.columns.select {|c| c.name == "#{field}_#{I18n.locale}"}.length > 0
- self.send("#{field}_#{I18n.locale}".to_sym)
- else
- super()
- end
- end
-
- # Define the setter
- define_method("#{field}=") do |val|
- if self.class.columns.select {|c| c.name == "#{field}_#{I18n.locale}"}.length > 0
- self["#{field}_#{I18n.locale}".to_sym] = val
- else
- self[field.to_sym] = val
- end
- end
- end
- end
- end
-end
+puts "yeeeeeeee"
+require 'has_foreign_language/i18n'
+require 'has_foreign_language/form_fix'
+require 'has_foreign_language/init'
View
0 lib/form_fix.rb → lib/has_foreign_language/form_fix.rb
File renamed without changes.
View
47 lib/has_foreign_language/i18n.rb
@@ -0,0 +1,47 @@
+# HasForeignLanguage
+module HasForeignLanguage
+
+ module I18n
+
+ def self.included(mod)
+ mod.extend(ClassMethods)
+ end
+
+ module ClassMethods
+
+ def has_foreign_language(*args)
+ args.each do |field|
+
+ # Define the marker
+ eigenclass = class << self
+ self
+ end
+ eigenclass.class_eval do
+ define_method("has_foreign_language_#{field.to_s}?") { true }
+ end
+
+ # Define the getter
+ define_method(field.to_s) do
+ if self.class.columns.select {|c| c.name == "#{field}_#{I18n.locale}"}.length > 0
+ self.send("#{field}_#{I18n.locale}".to_sym)
+ else
+ super()
+ end
+ end
+
+ # Define the setter
+ define_method("#{field}=") do |val|
+ if self.class.columns.select {|c| c.name == "#{field}_#{I18n.locale}"}.length > 0
+ self["#{field}_#{I18n.locale}".to_sym] = val
+ else
+ self[field.to_sym] = val
+ end
+ end
+ end
+ end
+
+ end
+
+ end
+
+end
View
6 lib/has_foreign_language/init.rb
@@ -0,0 +1,6 @@
+# Include hook code here
+
+ActiveRecord::Base.send(:include, HasForeignLanguage::I18n)
+
+
+#ActionView::Helpers::FormHelper.send(:extend, FormFix)

0 comments on commit 8ad0000

Please sign in to comment.
Something went wrong with that request. Please try again.