lib/jets/rule/dsl.rb in jets-0.6.8 vs lib/jets/rule/dsl.rb in jets-0.6.9
- old
+ new
@@ -39,11 +39,10 @@
def maximum_execution_frequency(value)
config_rule(maximum_execution_frequency: value)
end
- # not really meant to be used but provided for completeness
def source(value)
config_rule(source: value)
end
def config_rule(options={})
@@ -55,10 +54,38 @@
# Creates instances of Rule::Task instead of a Lambda::Task
# Also adds the config_rule option that is specific to Rule classes
def register_task(meth, lang=:ruby)
all_tasks[meth] = Jets::Rule::Task.new(self.name, meth,
properties: @properties, config_rule: @config_rule, lang: lang)
+ clear_properties
true
+ end
+
+ def clear_properties
+ super
+ @config_rule = nil
+ end
+
+ ## aws managed rules work different enough to merit their own storage
+
+ def all_managed_rules
+ @all_managed_rules ||= ActiveSupport::OrderedHash.new
+ end
+
+ def managed_rules
+ all_managed_rules.values
+ end
+
+ def managed_rule(meth)
+ all_managed_rules[meth] = Jets::Rule::AwsManagedRule.new(self.name, meth,
+ properties: @properties, config_rule: @config_rule)
+ clear_properties
+ true
+ end
+
+ # Override Lambda::Dsl.build? to account of possible managed_rules
+ def build?
+ !tasks.empty? || !managed_rules.empty?
end
end
end
end