Class: Wordmove::Guardian

Inherits:
Object
  • Object
show all
Defined in:
lib/wordmove/guardian.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options[:config])
  @environment = @movefile.environment(options).to_sym
  @action = action
  @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/wordmove/guardian.rb', line 3

def action
  @action
end

#environmentObject (readonly)

Returns the value of attribute environment.



3
4
5
# File 'lib/wordmove/guardian.rb', line 3

def environment
  @environment
end

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'lib/wordmove/guardian.rb', line 3

def logger
  @logger
end

#movefileObject (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