Class: Lutaml::Rdf::Mapping
Instance Attribute Summary collapse
Instance Method Summary
collapse
#add_listener, #all_listeners, #ensure_mappings_imported!, #inherit_from, #listeners_for, #omit_element, #omit_listener, #parent_mapping
Constructor Details
Returns a new instance of Mapping.
9
10
11
12
13
14
15
16
|
# File 'lib/lutaml/rdf/mapping.rb', line 9
def initialize
super
@namespace_set = Lutaml::Rdf::NamespaceSet.new
@rdf_subject = nil
@rdf_type = nil
@rdf_predicates = []
@rdf_members = []
end
|
Instance Attribute Details
#namespace_set ⇒ Object
Returns the value of attribute namespace_set.
6
7
8
|
# File 'lib/lutaml/rdf/mapping.rb', line 6
def namespace_set
@namespace_set
end
|
#rdf_members ⇒ Object
Returns the value of attribute rdf_members.
6
7
8
|
# File 'lib/lutaml/rdf/mapping.rb', line 6
def rdf_members
@rdf_members
end
|
#rdf_predicates ⇒ Object
Returns the value of attribute rdf_predicates.
6
7
8
|
# File 'lib/lutaml/rdf/mapping.rb', line 6
def rdf_predicates
@rdf_predicates
end
|
#rdf_subject ⇒ Object
Returns the value of attribute rdf_subject.
6
7
8
|
# File 'lib/lutaml/rdf/mapping.rb', line 6
def rdf_subject
@rdf_subject
end
|
#rdf_type ⇒ Object
Returns the value of attribute rdf_type.
6
7
8
|
# File 'lib/lutaml/rdf/mapping.rb', line 6
def rdf_type
@rdf_type
end
|
Instance Method Details
#deep_dup ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/lutaml/rdf/mapping.rb', line 59
def deep_dup
self.class.new.tap do |new_mapping|
new_mapping.instance_variable_set(:@namespace_set, @namespace_set)
new_mapping.instance_variable_set(:@rdf_subject, @rdf_subject)
new_mapping.instance_variable_set(:@rdf_type, @rdf_type)
new_mapping.instance_variable_set(:@rdf_predicates,
@rdf_predicates.dup)
new_mapping.instance_variable_set(:@rdf_members, @rdf_members.dup)
end
end
|
#finalize(_mapper_class) ⇒ Object
47
|
# File 'lib/lutaml/rdf/mapping.rb', line 47
def finalize(_mapper_class); end
|
#finalized? ⇒ Boolean
49
50
51
|
# File 'lib/lutaml/rdf/mapping.rb', line 49
def finalized?
true
end
|
#map_element(name, to:) ⇒ Object
53
54
55
56
57
|
# File 'lib/lutaml/rdf/mapping.rb', line 53
def map_element(name, to:)
raise Lutaml::Model::IncorrectMappingArgumentsError,
"RDF mappings use `predicate` instead of `map_element`. " \
"Use `predicate :#{name}, namespace: MyNs, to: :#{to}` inside `rdf do`."
end
|
#mappings(_register_id = nil) ⇒ Object
43
44
45
|
# File 'lib/lutaml/rdf/mapping.rb', line 43
def mappings(_register_id = nil)
@rdf_predicates
end
|
#members(attr_name) ⇒ Object
39
40
41
|
# File 'lib/lutaml/rdf/mapping.rb', line 39
def members(attr_name)
@rdf_members << Lutaml::Rdf::MemberRule.new(attr_name)
end
|
#namespace(*namespace_classes) ⇒ Object
18
19
20
|
# File 'lib/lutaml/rdf/mapping.rb', line 18
def namespace(*namespace_classes)
@namespace_set = Lutaml::Rdf::NamespaceSet.new(*namespace_classes)
end
|
#predicate(name, namespace:, to:, lang_tagged: false) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/lutaml/rdf/mapping.rb', line 30
def predicate(name, namespace:, to:, lang_tagged: false)
@rdf_predicates << Lutaml::Rdf::MappingRule.new(
name,
namespace: namespace,
to: to,
lang_tagged: lang_tagged,
)
end
|
#subject ⇒ Object
22
23
24
|
# File 'lib/lutaml/rdf/mapping.rb', line 22
def subject(&)
@rdf_subject = Proc.new(&) if block_given?
end
|
#type(value) ⇒ Object
26
27
28
|
# File 'lib/lutaml/rdf/mapping.rb', line 26
def type(value)
@rdf_type = value
end
|