Class: Brule::Rule

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

Direct Known Subclasses

Utils::Either

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



2
3
4
# File 'lib/brule/rule.rb', line 2

def config
  @config
end

#contextObject

Returns the value of attribute context.



3
4
5
# File 'lib/brule/rule.rb', line 3

def context
  @context
end

Class Method Details

.config_reader(*symbols) ⇒ Object



34
35
36
37
38
# File 'lib/brule/rule.rb', line 34

def self.config_reader(*symbols)
  symbols.each do |symbol|
    define_method(symbol) { config.fetch(symbol) }
  end
end

.context_accessor(*symbols) ⇒ Object



29
30
31
32
# File 'lib/brule/rule.rb', line 29

def self.context_accessor(*symbols)
  context_reader(*symbols)
  context_writer(*symbols)
end

.context_reader(*symbols) ⇒ Object



17
18
19
20
21
# File 'lib/brule/rule.rb', line 17

def self.context_reader(*symbols)
  symbols.each do |symbol|
    define_method(symbol) { context.fetch(symbol) }
  end
end

.context_writer(*symbols) ⇒ Object



23
24
25
26
27
# File 'lib/brule/rule.rb', line 23

def self.context_writer(*symbols)
  symbols.each do |symbol|
    define_method("#{symbol}=") { |value| context[symbol] = value }
  end
end

Instance Method Details

#applyObject

Raises:

  • (NotImplementedError)


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

def apply
  raise NotImplementedError
end

#to_tagObject



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

def to_tag
  self
end

#trigger?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/brule/rule.rb', line 5

def trigger?
  true
end