Class: Lutaml::Rdf::Mapping
Instance Attribute Summary collapse
Instance Method Summary
collapse
#add_listener, #all_listeners, #duplicate_mappings, #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 = []
@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
74
75
76
|
# File 'lib/lutaml/rdf/mapping.rb', line 74
def deep_dup
dup
end
|
#finalize(_mapper_class) ⇒ Object
62
|
# File 'lib/lutaml/rdf/mapping.rb', line 62
def finalize(_mapper_class); end
|
#finalized? ⇒ Boolean
64
65
66
|
# File 'lib/lutaml/rdf/mapping.rb', line 64
def finalized?
true
end
|
#has_types_or_predicates? ⇒ Boolean
34
35
36
|
# File 'lib/lutaml/rdf/mapping.rb', line 34
def has_types_or_predicates?
@rdf_type.any? || @rdf_predicates.any?
end
|
#initialize_copy(source) ⇒ Object
78
79
80
81
82
83
|
# File 'lib/lutaml/rdf/mapping.rb', line 78
def initialize_copy(source)
super
@rdf_type = source.rdf_type.dup
@rdf_predicates = source.rdf_predicates.dup
@rdf_members = source.rdf_members.dup
end
|
#map_element(name, to:) ⇒ Object
68
69
70
71
72
|
# File 'lib/lutaml/rdf/mapping.rb', line 68
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
58
59
60
|
# File 'lib/lutaml/rdf/mapping.rb', line 58
def mappings(_register_id = nil)
@rdf_predicates
end
|
#members(attr_name, predicate_name: nil, namespace: nil, link: nil) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/lutaml/rdf/mapping.rb', line 49
def members(attr_name, predicate_name: nil, namespace: nil, link: nil)
@rdf_members << Lutaml::Rdf::MemberRule.new(
attr_name,
predicate_name: predicate_name,
namespace: namespace,
link: link,
)
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, uri_reference: false) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/lutaml/rdf/mapping.rb', line 38
def predicate(name, namespace:, to:, lang_tagged: false,
uri_reference: false)
@rdf_predicates << Lutaml::Rdf::MappingRule.new(
name,
namespace: namespace,
to: to,
lang_tagged: lang_tagged,
uri_reference: uri_reference,
)
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 = Array(value)
end
|
#types(*values) ⇒ Object
30
31
32
|
# File 'lib/lutaml/rdf/mapping.rb', line 30
def types(*values)
@rdf_type = values.flatten
end
|