Class: PyrRules::RuleContext
- Inherits:
-
Object
- Object
- PyrRules::RuleContext
- Defined in:
- app/rules/pyr_rules/rule_context.rb
Instance Method Summary collapse
- #get_binding ⇒ Object
-
#initialize(event_hash, extras = {}) ⇒ RuleContext
constructor
A new instance of RuleContext.
Constructor Details
#initialize(event_hash, extras = {}) ⇒ RuleContext
Returns a new instance of RuleContext.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/rules/pyr_rules/rule_context.rb', line 2 def initialize(event_hash, extras = {}) event_hash.each do |key, value| define_singleton_method(key.to_sym) {value} end extras.each do |key, value| define_singleton_method(key.to_sym) {value} end define_singleton_method(:system) {:system_messaging_user} target = event_hash[:klazz].constantize.find event_hash[:id].to_i rescue nil actor = User.find event_hash[:user][:id].to_i rescue nil actor ||= target.try(:user) rescue nil define_singleton_method(:target) {target} define_singleton_method(:actor) {actor} end |
Instance Method Details
#get_binding ⇒ Object
16 17 18 |
# File 'app/rules/pyr_rules/rule_context.rb', line 16 def get_binding return binding end |