Skip to content

Commit

Permalink
Use Class.new block instead of instance_eval
Browse files Browse the repository at this point in the history
  • Loading branch information
abyx committed Mar 19, 2011
1 parent f7fae6d commit d588402
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/values.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class Value
def self.new(*fields)
value_class = Class.new
value_class.instance_eval do
return Class.new do
attr_reader *fields
define_method(:initialize) do |*input_fields|
raise ArgumentError.new("wrong number of arguments, #{input_fields.size} for #{fields.size}") if fields.size != input_fields.size
Expand All @@ -12,6 +11,5 @@ def self.new(*fields)
self.freeze
end
end
return value_class
end
end

0 comments on commit d588402

Please sign in to comment.