module RGovData::Dn

This module defines the basic naming interface for catalog objects Override these methods as required

Public Instance Methods

attributes() click to toggle source

Returns array of attributes that describe the records of the specific entity By default, it is nil (meaning indeterminate)

# File lib/rgovdata/catalog/dn.rb, line 50
def attributes
  @attributes
end
id() click to toggle source

Returns the human-readable unique id

# File lib/rgovdata/catalog/dn.rb, line 6
def id
  nameparts = []
  if defined? realm
    nameparts.push('/')
    nameparts.push(realm)
  end
  nameparts.push(service_key) if defined?(service_key) && service_key.present?
  nameparts.push(dataset_key) if defined?(dataset_key) && dataset_key.present?
  nameparts.join('/')
end
initialization_hash() click to toggle source

Returns a hash that fully describes this service and can be used as a parameter to new By default, returns a hash based on meta_attributes

# File lib/rgovdata/catalog/dn.rb, line 40
def initialization_hash
  h = {}
  meta_attributes.each do |attribute|
    h.merge!(attribute => self.send(attribute))
  end
  h
end
meta_attributes() click to toggle source

Returns array of attributes that describe the specific entity By default, guesses based on instance variables

# File lib/rgovdata/catalog/dn.rb, line 29
def meta_attributes
  a = [:id]
  instance_variables.each do |v|
    n = v.to_s.gsub('@','').to_sym
    a << n if self.respond_to?(n)
  end
  a
end
records() click to toggle source

Generic interface to return the currently applicable record set

# File lib/rgovdata/catalog/dn.rb, line 55
def records
  if defined? datasets
    datasets
  else
    []
  end
end
to_param() click to toggle source

Returns a rails-compatible ID

# File lib/rgovdata/catalog/dn.rb, line 18
def to_param
  id.gsub('/',':')
end
to_s() click to toggle source

Returns the human version of the object name/identification

# File lib/rgovdata/catalog/dn.rb, line 23
def to_s
  "#{id} [#{self.class.name}]"
end