Class: Wrong::Config
- Inherits:
-
Hash
show all
- Defined in:
- lib/wrong/config.rb,
lib/wrong/adapters/rspec.rb,
lib/wrong/adapters/rspec.rb
Defined Under Namespace
Classes: ConfigError
Instance Method Summary
collapse
Constructor Details
#initialize(string = nil) ⇒ Config
Returns a new instance of Config.
28
29
30
31
32
33
|
# File 'lib/wrong/config.rb', line 28
def initialize(string = nil)
self[:aliases] = {:assert => [:assert], :deny => [:deny]}
if string
instance_eval string.gsub(/^(.*=)/, "self.\\1")
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, value = true) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/wrong/config.rb', line 35
def method_missing(name, value = true)
name = name.to_s
if name =~ /=$/
name.gsub!(/=$/, '')
end
self[name.to_sym] = value
end
|
Instance Method Details
#alias_assert(method_name, options = {}) ⇒ Object
49
50
51
|
# File 'lib/wrong/config.rb', line 49
def alias_assert(method_name, options = {})
alias_assert_or_deny(:assert, method_name, options)
end
|
#alias_assert_or_deny(valence, extra_name, options = {}) ⇒ Object
43
44
45
46
47
|
# File 'lib/wrong/config.rb', line 43
def alias_assert_or_deny(valence, , options)
Wrong::Assert.send(:alias_method, , valence)
new_method_name = .to_sym
self[:aliases][valence] << new_method_name unless self[:aliases][valence].include?(new_method_name)
end
|
#alias_assert_or_deny_original ⇒ Object
42
43
44
45
46
|
# File 'lib/wrong/adapters/rspec.rb', line 42
def alias_assert_or_deny(valence, , options)
Wrong::Assert.send(:alias_method, , valence)
new_method_name = .to_sym
self[:aliases][valence] << new_method_name unless self[:aliases][valence].include?(new_method_name)
end
|
#alias_deny(method_name, options = {}) ⇒ Object
53
54
55
|
# File 'lib/wrong/config.rb', line 53
def alias_deny(method_name, options = {})
alias_assert_or_deny(:deny, method_name, options)
end
|
#assert_method_names ⇒ Object
57
58
59
|
# File 'lib/wrong/config.rb', line 57
def assert_method_names
self[:aliases][:assert]
end
|
#assert_methods ⇒ Object
65
66
67
|
# File 'lib/wrong/config.rb', line 65
def assert_methods
assert_method_names + deny_method_names
end
|
#deny_method_names ⇒ Object
61
62
63
|
# File 'lib/wrong/config.rb', line 61
def deny_method_names
self[:aliases][:deny]
end
|