lib/spread2rdf/mapping/cell.rb in spread2rdf-0.1.3 vs lib/spread2rdf/mapping/cell.rb in spread2rdf-0.1.4
- old
+ new
@@ -1,8 +1,9 @@
module Spread2RDF
module Mapping
class Cell < Element
+ include ResourceCreation
attr_reader :row
def_delegators :parent, :subject, :worksheet, :resource
def_delegators :schema, :predicate
@@ -22,10 +23,11 @@
end
def value
@value ||= worksheet.cell_value(coord)
end
+ alias resource_creation_value value
def object
@object ||= value && map_to_object(value)
end
@@ -35,13 +37,13 @@
def map_to_object(value)
case schema.object_mapping_mode
when :to_string then map_to_literal(value)
when :resource_ref then resolve_resource_ref
- when :new_resource then create_resource_object
+ when :new_resource then create_resource
when :custom then exec(&schema.cell_mapping)
- else raise 'internal error: unknown column mapping type'
+ else raise 'internal error: unknown column mapping mode'
end
end
private :map_to_object
def map_to_literal(value)
@@ -94,19 +96,9 @@
result = data_source.query([nil, predicate, map_to_literal(value)])
return nil if result.empty?
raise "#{self}: found multiple resources for #{value} in #{data_source_name}: #{result.map(&:subject)}" if result.count > 1
result.first.subject
end
-
- def create_resource_object
- case
- when (schema.object.try(:fetch, :uri, nil) || object) == :bnode
- RDF::Node.new
- else
- raise NotImplementedError
- end
- end
- private :create_resource_object
##########################################################################
# for the DSL for column statement blocks
def value_of_column(name)