Created
December 12, 2012 15:52
-
-
Save myronmarston/4268898 to your computer and use it in GitHub Desktop.
Playing around with sequel dataset wrapping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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