Class: Rule
- Inherits:
-
Object
show all
- Defined in:
- lib/wonko_the_sane/rules.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(action) ⇒ Rule
Returns a new instance of Rule.
4
5
6
|
# File 'lib/wonko_the_sane/rules.rb', line 4
def initialize(action)
@action = action
end
|
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
2
3
4
|
# File 'lib/wonko_the_sane/rules.rb', line 2
def action
@action
end
|
Class Method Details
.allowed_on_side(rules, side) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/wonko_the_sane/rules.rb', line 12
def self.allowed_on_side(rules, side)
allowed = :allow
rules.each do |rule|
if rule.is_a? ImplicitRule
allowed = rule.action
elsif rule.is_a? SidedRule
allowed = rule.action if rule.side = side
end
end
return allowed
end
|
.from_json(obj) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/wonko_the_sane/rules.rb', line 24
def self.from_json(obj)
if obj.key? :os
return OsRule.new obj[:action].to_sym, obj[:os][:name], obj[:os][:version], obj[:os][:arch]
elsif obj.key? :side
return SidedRule.new obj[:action].to_sym, obj[:side]
else
return ImplicitRule.new obj[:action].to_sym
end
end
|
Instance Method Details
#to_json ⇒ Object
8
9
10
|
# File 'lib/wonko_the_sane/rules.rb', line 8
def to_json
{ action: @action }
end
|