Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace options hash with memoized instance vars

  • Loading branch information...
commit 4960c017ba290b1e8f2f983abce0e9d7a0ab7598 1 parent b279db8
@paulelliott authored
Showing with 10 additions and 29 deletions.
  1. +10 −29 lib/fabrication/config.rb
View
39 lib/fabrication/config.rb
@@ -2,51 +2,32 @@ module Fabrication
module Config
extend self
- def configure
- yield self
+ def configure; yield self end
+
+ def reset_defaults
+ @fabricator_path = @path_prefix = @active_support = nil
end
def fabricator_path
- OPTIONS[:fabricator_path]
+ @fabricator_path ||= ['test/fabricators', 'spec/fabricators']
end
alias fabricator_dir fabricator_path
def fabricator_path=(folders)
- OPTIONS[:fabricator_path] = (Array.new << folders).flatten
+ @fabricator_path = (Array.new << folders).flatten
end
alias fabricator_dir= fabricator_path=
+ attr_writer :path_prefix
def path_prefix
- OPTIONS[:path_prefix]
- end
-
- def path_prefix=(prefix)
- OPTIONS[:path_prefix] = prefix
- end
-
- def reset_defaults
- OPTIONS.replace(DEFAULTS)
+ @path_prefix ||= defined?(Rails) ? Rails.root : "."
end
def active_support?
@active_support ||= defined?(ActiveSupport)
end
- def register_with_steps?
- OPTIONS[:register_with_steps]
- end
-
- def register_with_steps=(register)
- OPTIONS[:register_with_steps] = register
- end
-
- private
-
- DEFAULTS = {
- fabricator_path: ['test/fabricators', 'spec/fabricators'],
- register_with_steps: false,
- path_prefix: defined?(Rails) ? Rails.root : "."
- }
- OPTIONS = {}.merge!(DEFAULTS)
+ attr_writer :register_with_steps
+ def register_with_steps?; @register_with_steps end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.