Class: RDF::Tabular::Schema
- Defined in:
- lib/rdf/tabular/metadata.rb
Constant Summary collapse
- PROPERTIES =
{ :@id => :link, :@type => :atomic, columns: :array, foreignKeys: :array, primaryKey: :column_reference, }.freeze
- DEFAULTS =
{}.freeze
- REQUIRED =
[].freeze
Constants inherited from Metadata
Metadata::DATATYPES, Metadata::INHERITED_DEFAULTS, Metadata::INHERITED_PROPERTIES, Metadata::LOCAL_CONTEXT, Metadata::NAME_SYNTAX
Instance Attribute Summary
Attributes inherited from Metadata
#filenames, #id, #object, #parent, #url, #warnings
Instance Method Summary collapse
- #columns=(value) ⇒ Object
- #foreignKeys=(value) ⇒ Object
-
#method_missing(method, *args) ⇒ Object
Logic for accessing elements as accessors.
Methods inherited from Metadata
#==, #[], #[]=, #base, #common_properties, #context, #datatype=, #dialect, #dialect=, #each, #each_row, #errors, for_input, #has_annotations?, #initialize, #inspect, new, #normalize!, #normalize_jsonld, open, #tableSchema=, #tables=, #to_json, #transformations=, #type, #valid?, #valid_natural_language_property?, #validate!, #verify_compatible!
Methods included from Utils
Constructor Details
This class inherits a constructor from RDF::Tabular::Metadata
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Logic for accessing elements as accessors
1272 1273 1274 1275 1276 1277 1278 |
# File 'lib/rdf/tabular/metadata.rb', line 1272 def method_missing(method, *args) if INHERITED_PROPERTIES.has_key?(method.to_sym) inherited_property_value(method.to_sym) else PROPERTIES.has_key?(method.to_sym) ? object[method.to_sym] : super end end |
Instance Method Details
#columns=(value) ⇒ Object
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 |
# File 'lib/rdf/tabular/metadata.rb', line 1227 def columns=(value) object[:columns] = case value when Array number = 0 value.map do |v| number += 1 case v when Hash Column.new(v, @options.merge( table: (parent if parent.is_a?(Table)), parent: self, context: nil, number: number)) else v end end else warn "#{type} has invalid property 'columns': expected array of Column" [] end unless object[:columns].all? {|v| v.is_a?(Column)} warn "#{type} has invalid property 'columns': expected array of Column" # Remove elements that aren't of the right types object[:columns] = object[:columns].select! {|v| v.is_a?(Column)} end end |
#foreignKeys=(value) ⇒ Object
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 |
# File 'lib/rdf/tabular/metadata.rb', line 1256 def foreignKeys=(value) object[:foreignKeys] = case value when Array then value else warn "#{type} has invalid property 'foreignKeys': expected array of ForeignKey" [] end unless object[:foreignKeys].all? {|v| v.is_a?(Hash)} warn "#{type} has invalid property 'foreignKeys': expected array of ForeignKey" # Remove elements that aren't of the right types object[:foreignKeys] = object[:foreignKeys].select! {|v| v.is_a?(Hash)} end end |