Class: Wordmove::Guardian
- Inherits:
-
Object
- Object
- Wordmove::Guardian
- Defined in:
- lib/wordmove/guardian.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#movefile ⇒ Object
readonly
Returns the value of attribute movefile.
Instance Method Summary collapse
- #allows(task) ⇒ Object
-
#initialize(options: nil, action: nil) ⇒ Guardian
constructor
A new instance of Guardian.
Constructor Details
#initialize(options: nil, action: nil) ⇒ Guardian
Returns a new instance of Guardian.
5 6 7 8 9 10 |
# File 'lib/wordmove/guardian.rb', line 5 def initialize(options: nil, action: nil) @movefile = Wordmove::Movefile.new([:config]) @environment = @movefile.environment().to_sym @action = action @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG } end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/wordmove/guardian.rb', line 3 def action @action end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
3 4 5 |
# File 'lib/wordmove/guardian.rb', line 3 def environment @environment end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/wordmove/guardian.rb', line 3 def logger @logger end |
#movefile ⇒ Object (readonly)
Returns the value of attribute movefile.
3 4 5 |
# File 'lib/wordmove/guardian.rb', line 3 def movefile @movefile end |
Instance Method Details
#allows(task) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/wordmove/guardian.rb', line 12 def allows(task) if forbidden?(task) logger.task("#{action.capitalize}ing #{task.capitalize}") logger.warn("You tried to #{action} #{task}, but is forbidden by configuration. Skipping") end !forbidden?(task) end |