Created
April 28, 2015 10:49
-
-
Save solnic/3e9e54ac948fc6be7678 to your computer and use it in GitHub Desktop.
ROM - DataProxy + Options usage example
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 '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