Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Cairo Noleto committed Jun 13, 2012
1 parent faba4e0 commit bbd8478
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/i18n_alchemy/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ def method_missing(*args, &block)
private

def active_record_compatible?
target_class = @target.class
target_class.respond_to?(:columns) && target_class.respond_to?(:nested_attributes_options)
end

def build_attributes
@target.class.columns.each do |column|
columns.each do |column|
column_name = column.name
next if column.primary || column_name.ends_with?("_id") || @localized_attributes.key?(column_name)

Expand All @@ -68,7 +67,7 @@ def build_attributes
end

def build_methods
@target.class.localized_methods.each_pair do |method, parser_type|
localized_methods.each_pair do |method, parser_type|
method = method.to_s
parser = detect_parser(parser_type)
build_attribute(method, parser)
Expand Down Expand Up @@ -133,6 +132,18 @@ def detect_parser(type_or_parser)
type_or_parser
end
end

def localized_methods
target_class.localized_methods
end

def columns
target_class.columns
end

def target_class
@target.class
end
end
end
end

0 comments on commit bbd8478

Please sign in to comment.