module Krikri::MappingDSL::ParserMethods

Implements methods for accessing parsed values in MappingDSL

Public Instance Methods

header() click to toggle source

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

@return [Proc] a proc that, when called, returns the rdf_subject of the

OriginalRecord associated with the parsed record passed as its argument.

@todo consider a more generalized approach

# File lib/krikri/mapping_dsl/parser_methods.rb, line 50
def header
  RecordProxy.new(
    [{ name: :header }],
    Krikri::Parser::ValueArray,
    true)
end
local_name() click to toggle source

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

@return [Proc] a proc that, when called, returns the local_name of the

OriginalRecord associated with the parsed record passed as its argument.
# File lib/krikri/mapping_dsl/parser_methods.rb, line 24
def local_name
  lambda do |parsed|
    parsed.record.local_name
  end
end
record() click to toggle source

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

@return [RecordProxy] a RecordProxy providing delayed method calls against

a parsed record.

@see Krikri::MappingDSL::ParserMethods::RecordProxy

# File lib/krikri/mapping_dsl/parser_methods.rb, line 14
def record
  RecordProxy.new
end
record_uri() click to toggle source

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

@return [Proc] a proc that, when called, returns the rdf_subject of the

OriginalRecord associated with the parsed record passed as its argument.
# 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