Class: Wizard::Spells::Base
- Inherits:
-
Object
- Object
- Wizard::Spells::Base
- Includes:
- Helpers
- Defined in:
- lib/wizard/spells/base.rb
Direct Known Subclasses
Constant Summary
Constants included from Helpers
Class Method Summary collapse
-
.all_forced? ⇒ Boolean
Should all actions be performed in force mode?.
-
.attr_status(*statuses) ⇒ Object
Creates shortcuts for given statuses:.
-
.force_all! ⇒ Object
Set force mode for all apps.
Instance Method Summary collapse
-
#force! ⇒ Object
Set force mode for current action.
-
#force_all! ⇒ Object
See Ryori::Makers::Base.force_all! for details.
-
#forced? ⇒ Boolean
Should be forced performing of current action?.
-
#status ⇒ Object
Returns status of currently performed operation.
-
#status?(status) ⇒ Boolean
Returns
true
when actual status equals the given one.
Methods included from Helpers
#adjust, #colorize, #console_width, #print, #say, #say!
Class Method Details
.all_forced? ⇒ Boolean
Should all actions be performed in force mode?
9 10 11 |
# File 'lib/wizard/spells/base.rb', line 9 def all_forced? defined?(@@force_all) and !!@@force_all end |
.attr_status(*statuses) ⇒ Object
Creates shortcuts for given statuses:
attr_status :my_status
will produce methods:
my_status! # => status!(:my_status)
my_status? # => status?(:my_status)
28 29 30 31 32 33 34 |
# File 'lib/wizard/spells/base.rb', line 28 def attr_status(*statuses) statuses.each do |status| define_method("#{status}!".to_sym) { status!(status.to_sym) } define_method("#{status}?".to_sym) { status?(status.to_sym) } protected "#{status}!".to_sym end end |
.force_all! ⇒ Object
Set force mode for all apps. XXX. deadlocks can raise here.
15 16 17 |
# File 'lib/wizard/spells/base.rb', line 15 def force_all! @@force_all = true end |
Instance Method Details
#force! ⇒ Object
Set force mode for current action.
67 68 69 |
# File 'lib/wizard/spells/base.rb', line 67 def force! @force = true end |
#force_all! ⇒ Object
See Ryori::Makers::Base.force_all! for details.
62 63 64 |
# File 'lib/wizard/spells/base.rb', line 62 def force_all! self.class.force_all! end |
#forced? ⇒ Boolean
Should be forced performing of current action?
57 58 59 |
# File 'lib/wizard/spells/base.rb', line 57 def forced? @force || self.class.all_forced? end |
#status ⇒ Object
Returns status of currently performed operation.
42 43 44 |
# File 'lib/wizard/spells/base.rb', line 42 def status @status end |
#status?(status) ⇒ Boolean
Returns true
when actual status equals the given one.
status!(:success)
status?(:success) # => true
status?(:error) # => false
52 53 54 |
# File 'lib/wizard/spells/base.rb', line 52 def status?(status) self.status == status.to_sym end |