Skip to content

Commit

Permalink
add positional information to all instances of eval
Browse files Browse the repository at this point in the history
  • Loading branch information
mguterl committed Feb 25, 2010
1 parent 6f63e10 commit fc632db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/attribute_mapper.rb
Expand Up @@ -51,7 +51,7 @@ def map_attribute(attribute, options)
private

def add_accessor_for(attribute, mapping)
class_eval(<<-EVAL)
class_eval(<<-EVAL, __FILE__, __LINE__)
class << self
def #{attribute.to_s.pluralize}
#{mapping.inspect}
Expand All @@ -62,7 +62,7 @@ def #{attribute.to_s.pluralize}

def add_predicates_for(attribute, names)
names.each do |name|
class_eval(<<-RUBY)
class_eval(<<-RUBY, __FILE__, __LINE__)
def #{name}?
self.#{attribute} == :#{name}
end
Expand All @@ -89,15 +89,15 @@ def override(*args)
end

def override_getters(attribute)
class_eval(<<-EVAL)
class_eval(<<-EVAL, __FILE__, __LINE__)
def #{attribute}
self.class.#{attribute.to_s.pluralize}.invert[read_attribute(:#{attribute})]
end
EVAL
end

def override_setters(attribute)
class_eval(<<-EVAL)
class_eval(<<-EVAL, __FILE__, __LINE__)
def #{attribute}=(raw_value)
value = resolve_value_of :#{attribute}, raw_value
write_attribute(:#{attribute}, value)
Expand Down

0 comments on commit fc632db

Please sign in to comment.