Class: SSH::Allow::RuleSet

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh/allow/rule_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRuleSet

Returns a new instance of RuleSet.



6
7
8
# File 'lib/ssh/allow/rule_set.rb', line 6

def initialize
  @rules = []
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules.



4
5
6
# File 'lib/ssh/allow/rule_set.rb', line 4

def rules
  @rules
end

Instance Method Details

#allow(cmd, &block) ⇒ Object



10
11
12
# File 'lib/ssh/allow/rule_set.rb', line 10

def allow(cmd, &block)
  push get_rule(:allow, cmd, block)
end

#allow!(cmd, &block) ⇒ Object



14
15
16
17
# File 'lib/ssh/allow/rule_set.rb', line 14

def allow!(cmd, &block)
  rule = get_rule(:allow, cmd, block)
  push(rule) or raise(%(Invalid rule: "#{cmd}"))
end

#read(path_to_rules) ⇒ Object



19
20
21
# File 'lib/ssh/allow/rule_set.rb', line 19

def read(path_to_rules)
  self.instance_eval(read_rules(path_to_rules))
end