Module: Krikri::MappingDSL::ParserMethods

Extended by:
ActiveSupport::Concern
Included in:
Krikri::MappingDSL
Defined in:
lib/krikri/mapping_dsl/parser_methods.rb

Overview

Implements methods for accessing parsed values in MappingDSL

Defined Under Namespace

Classes: RecordProxy

Instance Method Summary collapse

Instance Method Details

#headerProc

TODO:

consider a more generalized approach

Gives access to a delayed call for the ‘#header` of a parsed record.

Returns:

  • (Proc)

    a proc that, when called, returns the #rdf_subject of the OriginalRecord associated with the parsed record passed as its argument.



50
51
52
53
54
55
# File 'lib/krikri/mapping_dsl/parser_methods.rb', line 50

def header
  RecordProxy.new(
    [{ name: :header }],
    Krikri::Parser::ValueArray,
    true)
end

#local_nameProc

Gives access to a delayed call for the ‘#local_name` of an OriginalRecord, to be executed at the time the mapping is processed.

Returns:

  • (Proc)

    a proc that, when called, returns the #local_name of the OriginalRecord associated with the parsed record passed as its argument.



24
25
26
27
28
# File 'lib/krikri/mapping_dsl/parser_methods.rb', line 24

def local_name
  lambda do |parsed|
    parsed.record.local_name
  end
end

#recordRecordProxy

Gives access to delayed method calls on parsed record ValueArrays, to be executed at the time the mapping is processed.

Returns:

  • (RecordProxy)

    a RecordProxy providing delayed method calls against a parsed record.

See Also:



14
15
16
# File 'lib/krikri/mapping_dsl/parser_methods.rb', line 14

def record
  RecordProxy.new
end

#record_uriProc

Gives access to a delayed call for the ‘#rdf_subject` of an OriginalRecord, to be executed at the time the mapping is processed.

Returns:

  • (Proc)

    a proc that, when called, returns the #rdf_subject of the OriginalRecord associated with the parsed record passed as its argument.



36
37
38
39
40
41
42
# File 'lib/krikri/mapping_dsl/parser_methods.rb', line 36

def record_uri
  lambda do |parsed|
    raise "Tried to access subject URI for #{parsed.record}, " \
    "but it is not saved." unless parsed.record.exists?
    parsed.record.rdf_subject
  end
end