Sha256: af866c52f90d5e09ae6e3eb47aafcb03e05302c01eedc90d2c34ac6386f8ecb0
Contents?: true
Size: 922 Bytes
Versions: 2
Compression:
Stored size: 922 Bytes
Contents
module Krikri::MappingDSL ## # Methods for setting URI/ActiveTriples #rdf_subject values in MappingDSL module RdfSubjects def uri(value, &block) properties.delete_if { |prop| prop.is_a? SubjectDeclaration } properties << SubjectDeclaration.new(nil, value, &block) end class SubjectDeclaration < Krikri::MappingDSL::PropertyDeclaration def to_proc block = @block if @block value = @value lambda do |target, record| value = value.call(record) if value.respond_to? :call raise "URI must be set to a single value; got #{value}" if Array(value).count != 1 value = value.first if value.is_a? Enumerable return target.send(setter, value) unless block target.send(setter, instance_exec(value, &block)) end end private def setter :set_subject! end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
krikri-0.1.1 | lib/krikri/mapping_dsl/rdf_subjects.rb |
krikri-0.1.0 | lib/krikri/mapping_dsl/rdf_subjects.rb |