Module: Avm::Scms::AutoCommit::Rules
- Defined in:
- lib/avm/scms/auto_commit/rules.rb,
lib/avm/scms/auto_commit/rules/new.rb,
lib/avm/scms/auto_commit/rules/nth.rb,
lib/avm/scms/auto_commit/rules/base.rb,
lib/avm/scms/auto_commit/rules/last.rb,
lib/avm/scms/auto_commit/rules/manual.rb,
lib/avm/scms/auto_commit/rules/unique.rb
Defined Under Namespace
Classes: Base, Last, Manual, New, Nth, Unique
Constant Summary
collapse
- RULES_CLASSES =
%w[last manual new nth unique]
.map { |key| ::Avm::Scms::AutoCommit::Rules.const_get(key.camelcase) }
Class Method Summary
collapse
Class Method Details
16
17
18
|
# File 'lib/avm/scms/auto_commit/rules.rb', line 16
def all
RULES_CLASSES
end
|
.parse(string) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/avm/scms/auto_commit/rules.rb', line 20
def parse(string)
parts = string.split(':')
klass = rule_class_by_key(parts.shift)
klass.new(*parts)
end
|
.rule_class_by_key(key) ⇒ Object
27
28
29
30
31
|
# File 'lib/avm/scms/auto_commit/rules.rb', line 27
def rule_class_by_key(key)
RULES_CLASSES.find { |klass| klass.keys.include?(key) } ||
raise("Rule not find with key \"#{key}\" (Available: " +
RULES_CLASSES.flat_map(&:keys).join(', ') + ')')
end
|