lib/pickle/config.rb in pickle-0.3.3 vs lib/pickle/config.rb in pickle-0.3.4
- old
+ new
@@ -1,7 +1,5 @@
-require 'ostruct'
-
module Pickle
class Config
attr_writer :adapters, :factories, :mappings, :predicates
def initialize(&block)
@@ -29,20 +27,23 @@
def predicates
@predicates ||= Pickle::Adapter.model_classes.map do |k|
k.public_instance_methods.select {|m| m =~ /\?$/} + Pickle::Adapter.column_names(k)
end.flatten.uniq
end
+
+ class Mapping < Struct.new(:search, :replacement)
+ end
def mappings
@mappings ||= []
end
# Usage: map 'me', 'myself', 'I', :to => 'user: "me"'
def map(*args)
options = args.extract_options!
raise ArgumentError, "Usage: map 'search' [, 'search2', ...] :to => 'replace'" unless args.any? && options[:to].is_a?(String)
args.each do |search|
- self.mappings << OpenStruct.new(:search => search, :replacement => options[:to])
+ self.mappings << Mapping.new(search, options[:to])
end
end
end
end