Class: Togls::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/togls/rule.rb

Overview

Rule

The Rule is an abstract base class that is intended to act as an interface for other rules to be implemented against.

Direct Known Subclasses

Togls::Rules::Boolean, Togls::Rules::Group

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Rule

Returns a new instance of Rule.



9
10
11
# File 'lib/togls/rule.rb', line 9

def initialize(data = nil)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/togls/rule.rb', line 7

def data
  @data
end

Instance Method Details

#idObject



17
18
19
# File 'lib/togls/rule.rb', line 17

def id
  Togls::Helpers.sha1(self.class, @data)
end

#run(key, target = nil) ⇒ Object



13
14
15
# File 'lib/togls/rule.rb', line 13

def run(key, target = nil)
  raise Togls::NotImplemented, "Rule's #run method must be implemented"
end