Module: ASpaceImport::XML::SAX::ClassMethods

Defined in:
backend/app/converters/lib/xml_sax.rb

Instance Method Summary collapse

Instance Method Details

#and_in_closing(path, &block) ⇒ Object



31
32
33
# File 'backend/app/converters/lib/xml_sax.rb', line 31

def and_in_closing(path, &block)
  define_method(handler_name(path, "_closing"), block)
end

#ensure_configurationObject



41
42
43
44
45
46
47
# File 'backend/app/converters/lib/xml_sax.rb', line 41

def ensure_configuration
  @configured ||= false
  @stickies = []
  unless @configured
    self.configure
  end
end

#handler_name(path, prefix = '') ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'backend/app/converters/lib/xml_sax.rb', line 15

def handler_name(path, prefix = '' )
  @sticky_nodes ||= {}
  parts = path.split("/").reverse
  handler_name = prefix
  while parts.length > 1
    @sticky_nodes[parts.last] = true
    handler_name << "_#{parts.pop}"
  end

  handler_name << "_#{parts.pop}"
end

#ignore(path) ⇒ Object



35
36
37
38
# File 'backend/app/converters/lib/xml_sax.rb', line 35

def ignore(path)
  with(path) {|*| @ignore = true }
  and_in_closing(path) {|*| @ignore = false }
end

#make_sticky?(node_name) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'backend/app/converters/lib/xml_sax.rb', line 49

def make_sticky?(node_name)
  @sticky_nodes[node_name] || false
end

#with(path, &block) ⇒ Object



27
28
29
# File 'backend/app/converters/lib/xml_sax.rb', line 27

def with(path, &block)
  define_method(handler_name(path), block)
end