Class: Brule::Rule
- Inherits:
-
Struct
- Object
- Struct
- Brule::Rule
- Defined in:
- lib/brule/rule.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#context ⇒ Object
Returns the value of attribute context.
Class Method Summary collapse
- .config_reader(*symbols) ⇒ Object
- .context_accessor(*symbols) ⇒ Object
- .context_reader(*symbols) ⇒ Object
- .context_writer(*symbols) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config
2 3 4 |
# File 'lib/brule/rule.rb', line 2 def config @config end |
#context ⇒ Object
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
#apply ⇒ Object
9 10 11 |
# File 'lib/brule/rule.rb', line 9 def apply raise NotImplementedError end |
#to_tag ⇒ Object
13 14 15 |
# File 'lib/brule/rule.rb', line 13 def to_tag self end |
#trigger? ⇒ Boolean
5 6 7 |
# File 'lib/brule/rule.rb', line 5 def trigger? true end |