module DynamicModelQueryable::DynamicModelClassQueryable
DynamicModelClassQueryable
contains class methods for dynamic DwCR
models.
Public Instance Methods
attribute_for(column_name)
click to toggle source
Returns the Metaschema::Attribute for a column_name
(the header of the column, can be passed as Symbol or String).
# File lib/dwcr/dynamic_model_queryable.rb, line 9 def attribute_for(column_name) entity.attributes_dataset.first(name: column_name.to_s) end
entity()
click to toggle source
Returns the Metschema::Entity the class belongs to.
# File lib/dwcr/dynamic_model_queryable.rb, line 14 def entity @entity end
template(keys = :term)
click to toggle source
Returns a nested array of all terms in the order values will be returned by to_a. Each item in the nested array will be an array with the entity term at index 0 and the attribute term at index 1.
# File lib/dwcr/dynamic_model_queryable.rb, line 21 def template(keys = :term) tmpl = columns.map do |column| next unless attribute = attribute_for(column) [attribute.send(keys), entity.send(keys)] end.compact return tmpl.compact unless entity.is_core entity.extensions.each do |xtn| tmpl << xtn.model_get.template(keys) end tmpl end
term()
click to toggle source
Returns the full DwC class term (a uri), including namespace.
# File lib/dwcr/dynamic_model_queryable.rb, line 34 def term entity.term end