Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some notes to Base about translators.

  • Loading branch information...
commit e905837de8c1d98dd19a2e1a604d3ed5efa6abcf 1 parent 7ffcd86
@technicalpickles technicalpickles authored committed
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/ambition/processors/base.rb
View
11 lib/ambition/processors/base.rb
@@ -93,15 +93,26 @@ def value(variable)
eval variable, @block
end
+ # Gives you the current translator. Uses +self.translator+ to look it up,
+ # if it isn't known yet.
def translator
@translator ||= self.class.translator(@context)
end
def self.translator(context, name = nil)
+ # Grok the adapter name
name ||= self.name.split('::').last
+ # Get the module for it
klass = context.owner.ambition_adapter.const_get(name)
instance = klass.new
+ # Make sure that the instance has everything it will need:
+ #
+ # * context
+ # * owner
+ # * clauses
+ # * stash
+ # * negated?
unless instance.respond_to? :context
klass.class_eval do
attr_accessor :context, :negated
Please sign in to comment.
Something went wrong with that request. Please try again.