Skip to content

Instantly share code, notes, and snippets.

@myronmarston
Created December 12, 2012 15:52
Show Gist options
  • Save myronmarston/4268898 to your computer and use it in GitHub Desktop.
Save myronmarston/4268898 to your computer and use it in GitHub Desktop.
Playing around with sequel dataset wrapping.
require 'forwardable'
module TopRankingKeyword
class DatasetWrapper
def initialize(ds)
@ds = ds
end
extend Forwardable
def_delegators :@ds, :sql
def tagged_with(*kws)
self
end
private
def wrap(ds)
self.class.new(ds)
end
end
class << self
attr_accessor :db
extend Forwardable
puts DatasetWrapper.public_instance_methods.join(' ')
def_delegators :dataset, *DatasetWrapper.public_instance_methods(false)
def dataset
DatasetWrapper.new(db[:keywords])
end
end
self.db = Shardonnay.db
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment