segmentio/analytics-ruby — pull request #9 by arronmabrey (2013-03-19 17:13:36+00:00)
Title: Move class methods into ClassMethods module for better extensibility.

My uses case is something along the lines of this.

```ruby
# /lib/segment_io.rb
module SegmentIO
CONFIG = OpenStruct.new(enabled: false)
extend AnalyticsRuby::ClassMethods

def self.config(&block)
yield CONFIG if block_given?
SegmentIO.init(secret: CONFIG.secret) if CONFIG.secret && CONFIG.enabled
end
end

# /config/initializers/segment_io.rb

SegmentIO.config do |config|
config.enabled = true
config.secret = ENV["SEGMENT_PRODUCTION_SECRET"] || 'dev-test-secret'
config.api_key = ENV["SEGMENT_PRODUCTION_APIKEY"] || 'dev-test-apikey'
end

# call it server side like.
SegmentIO.track(user_id: '53', event: 'Test Event')

# Also reference the api_key client side for javascript
# <% SegmentIO::CONFIG.api_key %>
```

This pull is to support the...
```ruby
...
extend AnalyticsRuby::ClassMethods
...
```
...bit above.