Module: Workbench
- Defined in:
- lib/workbench.rb,
lib/workbench/string_helpers.rb
Defined Under Namespace
Modules: StringHelpers
Constant Summary collapse
- COUNTERS =
Hash.new(0)
Class Method Summary collapse
-
.counter(key) ⇒ Object
The counter routine.
-
.reset_counters! ⇒ Object
Reset all counters.
Instance Method Summary collapse
-
#count_with(name) ⇒ Object
Declare that the next builder method is to count scoped to the following class.
-
#use_class(name) ⇒ Object
Declare that the next builder method is to use the said class.
Class Method Details
.counter(key) ⇒ Object
The counter routine. Provide a key, get back an incrementer.
56 57 58 |
# File 'lib/workbench.rb', line 56 def self.counter(key) COUNTERS[key] += 1 end |
.reset_counters! ⇒ Object
Reset all counters. It doesn’t happen automatically, you’ll likley want to call this method before or after each test is run
62 63 64 |
# File 'lib/workbench.rb', line 62 def self.reset_counters! COUNTERS.clear end |
Instance Method Details
#count_with(name) ⇒ Object
Declare that the next builder method is to count scoped to the following class
module Builders
extend Workbench
def book_defaults(u, n)
...
end
count_with :Book
def article_defaults(u, n)
...
end
end
new_book # n = 1
new_publication # n = 2
new_book # n = 3
Parameters:
name
-
a Symbol (ie :User) or string (is “Models::User”) that maps to a valid class name.
-
51 52 53 |
# File 'lib/workbench.rb', line 51 def count_with(name) @next_count_with = name end |
#use_class(name) ⇒ Object
Declare that the next builder method is to use the said class
module Builders
extend Workbench
def user_defaults(u)
...
end
use_class :User
def admin_user_defaults(u)
...
end
end
Parameters:
- name
-
Symbol such as :User or string such as “Models::User” are acceptable
-
24 25 26 |
# File 'lib/workbench.rb', line 24 def use_class(name) @next_class = name end |