Module: Ruckus::StructureFactory::ClassMethods

Defined in:
lib/ruckus/structure/factory.rb

Instance Method Summary collapse

Instance Method Details

#factory(str) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ruckus/structure/factory.rb', line 26

def factory(str)
    orig = str.clone
    (tmp = self.new).capture(str)
    tmp.each_field do |n, f|
        if (m = f.try(:decides))
            klass = m[f.value]
            if klass
                o = derive_search_module.const_get(klass.to_s.class_name).new
                if o.class.factory?
                    o, orig = o.class.factory(orig)
                else
                    orig = o.capture(orig)
                end
                return o, orig
            end
        end
    end
    return false
end