Skip to content

Instantly share code, notes, and snippets.

@solnic
Created April 28, 2015 10:49
Show Gist options
  • Save solnic/3e9e54ac948fc6be7678 to your computer and use it in GitHub Desktop.
Save solnic/3e9e54ac948fc6be7678 to your computer and use it in GitHub Desktop.
ROM - DataProxy + Options usage example
require 'rom'
require 'rom/support/options'
require 'rom/support/data_proxy'
class MyDataset
include ROM::Options
include ROM::DataProxy
option :connection, reader: true
def self.row_proc
Transproc(:symbolize_keys)
end
def initialize(data, options = {})
@data = data
super
end
end
data = [ { 'one' => 1 }, { 'two' => 2 } ]
ds = MyDataset.new(data, connection: 'I am connection')
puts ds.each.to_a.inspect
# [{:one=>1}, {:two=>2}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment