Sha256: 42f20fcf26351a116c6d3fc3de435311b511627cef9e699911ff7a3fd5ddeca1

Contents?: true

Size: 1.53 KB

Versions: 18

Compression:

Stored size: 1.53 KB

Contents

module TreasureData
module Logger

  module EventPreset
    def action(name, record, uid=TD.event.attribute[:uid])
      unless uid
        raise ArgumentError, "wrong number of arguments (2 for 3): :uid attribute is required"
      end
      post(name, record.merge({:action=>name.to_s, :uid=>uid}))
    end

    def register(uid=TD.event.attribute[:uid])
      unless uid
        raise ArgumentError, "wrong number of arguments (0 for 1): :uid attribute is required"
      end
      action(:register, {}, uid)
    end

    def login(uid=TD.event.attribute[:uid])
      unless uid
        raise ArgumentError, "wrong number of arguments (0 for 1): :uid attribute is required"
      end
      action(:login, {}, uid)
    end

    def pay(category, sub_category, name, price, count, uid=TD.event.attribute[:uid])
      unless uid
        raise ArgumentError, "wrong number of arguments (3 for 4): :uid attribute is required"
      end
      action(:pay, {:category=>category, :sub_category=>sub_category, :name=>name, :price=>price, :count=>count}, uid)
    end
  end

  class Event
    def initialize
      @attribute = {}
    end

    attr_accessor :attribute

    def post(action, record={})
      TreasureData::Logger.post(action, @attribute.merge(record))
    end

    def post_with_time(action, record, time)
      TreasureData::Logger.post_with_time(action, @attribute.merge(record), time)
    end

    def self.use(mod)
      send(:include, mod)
    end
  end

  Event.use EventPreset

  def self.event
    Thread.current[:td_event] ||= Event.new
  end

end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
td-logger-0.3.28 lib/td/logger/event.rb
td-logger-0.3.27 lib/td/logger/event.rb
td-logger-0.3.26 lib/td/logger/event.rb
td-logger-0.3.25 lib/td/logger/event.rb
td-logger-0.3.24 lib/td/logger/event.rb
td-logger-0.3.23 lib/td/logger/event.rb
td-logger-0.3.22 lib/td/logger/event.rb
td-logger-0.3.21 lib/td/logger/event.rb
td-logger-0.3.20 lib/td/logger/event.rb
td-logger-0.3.19 lib/td/logger/event.rb
td-logger-0.3.18 lib/td/logger/event.rb
td-logger-0.3.17 lib/td/logger/event.rb
td-logger-0.3.16 lib/td/logger/event.rb
td-logger-0.3.15 lib/td/logger/event.rb
td-logger-0.3.14 lib/td/logger/event.rb
td-logger-0.3.13 lib/td/logger/event.rb
td-logger-0.3.12 lib/td/logger/event.rb
td-logger-0.3.11 lib/td/logger/event.rb