Class: ROM::FMP::Gateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/rom/fmp/mini.rb,
lib/rom/fmp/gateway.rb,
lib/rom/fmp/micro02.rb,
lib/rom/fmp/micro01.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*options) ⇒ Gateway

Returns a new instance of Gateway.



22
23
24
25
26
27
# File 'lib/rom/fmp/mini.rb', line 22

def initialize(uri, options = {})
  puts "INITIALIZING GATEWAY WITH uri: #{uri} options: #{options}"
  @connection = connect(uri, options)
  @sets = {}
  self
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



8
9
10
# File 'lib/rom/fmp/gateway.rb', line 8

def database
  @database
end

#datasetsObject (readonly)

Returns the value of attribute datasets.



8
9
10
# File 'lib/rom/fmp/gateway.rb', line 8

def datasets
  @datasets
end

#setsObject (readonly)

Returns the value of attribute sets.



20
21
22
# File 'lib/rom/fmp/mini.rb', line 20

def sets
  @sets
end

Instance Method Details

#connect(*args) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rom/fmp/mini.rb', line 41

def connect(*args)
  options = args.last.kind_of?(Hash) ? args.pop : Hash.new
  options.merge! args.pop if args.last.kind_of?(Hash)
  case args[0]
  when Rfm::Database
    args[0]
  else
    #::Rfm::Database.new(uri[:database], *Array([uri.to_s, *args]).flatten)
    #Rfm.layout(storage_name, gateway.adapter.options.merge(FMRESULTSET_TEMPLATE).symbolize_keys)
    Rfm.database(*args, options.to_h.merge(FMRESULTSET_TEMPLATE).to_h)
  end
end

#dataset(name) ⇒ Object Also known as: []



29
30
31
# File 'lib/rom/fmp/mini.rb', line 29

def dataset(name)
  sets[name] = Dataset.new(name, connection)
end

#dataset?(name) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rom/fmp/mini.rb', line 37

def dataset?(name)
  sets.key?(name)
end