Module: Vero::Trackable::Base
- Included in:
- Vero::Trackable
- Defined in:
- lib/vero/trackable/base.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 |
# File 'lib/vero/trackable/base.rb', line 4 def self.included(base) @vero_trackable_map = [] base.extend(ClassMethods) end |
Instance Method Details
#to_vero ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vero/trackable/base.rb', line 27 def to_vero klass = self.class symbols, other = klass.trackable_map.partition { |i| i.is_a?(Symbol) } result = symbols.inject({}) do |hash, symbol| t = respond_to?(symbol) ? send(symbol) : nil hash[symbol] = t unless t.nil? hash end if other.is_a?(Array) && !other.empty? other.reject! { |i| !(i.is_a?(Hash) && i.has_key?(:extras)) } other.each do |h| symbol = h[:extras] t = respond_to?(symbol, true) ? send(symbol) : nil result.merge!(t) if t.is_a?(Hash) end end result[:email] = result.delete(:email_address) if result.has_key?(:email_address) result[:_user_type] = self.class.name result end |
#with_default_vero_context ⇒ Object
57 58 59 |
# File 'lib/vero/trackable/base.rb', line 57 def with_default_vero_context with_vero_context(Vero::App.default_context) end |
#with_vero_context(context = {}) ⇒ Object
51 52 53 54 55 |
# File 'lib/vero/trackable/base.rb', line 51 def with_vero_context(context = {}) context = Vero::Context.new(context) context.subject = self context end |