Class: Rfm::Factory::LayoutFactory

Inherits:
CaseInsensitiveHash show all
Defined in:
lib/rfm/utilities/factory.rb

Overview

:nodoc: all

Instance Method Summary (collapse)

Methods inherited from CaseInsensitiveHash

#[]=

Methods inherited from Hash

#_create_accessor, #_merge_object!, #rfm_filter, #rfm_only, #to_cih

Constructor Details

- (LayoutFactory) initialize(server, database)

extend Config config :parent=>'@database'



81
82
83
84
85
86
87
# File 'lib/rfm/utilities/factory.rb', line 81

def initialize(server, database)
	  	extend Config
	  	config :parent=>'@database'
  @server = server
  @database = database
  @loaded = false
end

Instance Method Details

- (Object) [](*args)

was layout_name



89
90
91
92
93
94
95
96
# File 'lib/rfm/utilities/factory.rb', line 89

def [](*args) # was layout_name
	options = get_config(*args)
	name = options[:strings].delete_at(0) || options[:layout]
  super(name) || (self[name] = Rfm::Layout.new(@database, *args))   #(name, @database, options))
  # This part reconfigures the named layout, if you pass it new config in the [] method.
				#   super(name).config({:layout=>name}.merge(options)) if options
				#   super(name)
end

- (Object) all



98
99
100
101
102
103
104
105
# File 'lib/rfm/utilities/factory.rb', line 98

def all
  if !@loaded
					c = Connection.new('-layoutnames', {"-db" => @database.name}, {:grammar=>'FMPXMLRESULT'}, @database)
					c.parse('fmpxml_minimal.yml', {})['data'].each{|k,v| (self[k] = Rfm::Layout.new(v['text'], @database)) if k.to_s != '' && v['text']}
    @loaded = true
  end
  self
end

- (Object) modelize(filter = /.*/)

Acquired from Rfm::Base



112
113
114
115
# File 'lib/rfm/utilities/factory.rb', line 112

def modelize(filter = /.*/)
	all.values.each{|lay| lay.modelize if lay.name.match(filter)}
	models
end

- (Object) models

Acquired from Rfm::Base



118
119
120
121
122
123
124
125
# File 'lib/rfm/utilities/factory.rb', line 118

def models
	rslt = {}
	each do |k,lay|
		layout_models = lay.models
		rslt[k] = layout_models if (!layout_models.nil? && !layout_models.empty?)
	end
	rslt
end

- (Object) names



107
108
109
# File 'lib/rfm/utilities/factory.rb', line 107

def names
	values.collect{|v| v.name}
end