class RGovData::DataSet

This is the catalog class that describes a generic Service DataSet

Attributes

native_service[R]
options[R]
service[R]

Public Class Methods

load_datasets(service) click to toggle source
# File lib/rgovdata/service/dataset/dataset.rb, line 9
def load_datasets(service)
  dataset_class = "RGovData::#{service.type.to_s.capitalize}DataSet".constantize
  ds = []
  service.dataset_keys.each do |dataset|
    ds << dataset_class.new({:dataset_key=>dataset},service)
  end
  ds
end
new(options,service) click to toggle source
# File lib/rgovdata/service/dataset/dataset.rb, line 19
def initialize(options,service)
  @options = if options.is_a?(Hash)
    OpenStruct.new(options)
  else
    OpenStruct.new
  end
  @service = service.dup # avoid circular dependencies
  @native_service = @service.try(:native_instance)
end

Public Instance Methods

attribute_value(row,attribute) click to toggle source

Returns the value of the named attribute from a recordset row Purpose is to encapsulate differences in addressing attribute values

# File lib/rgovdata/service/dataset/dataset.rb, line 72
def attribute_value(row,attribute)
  row.send(attribute)
end
dataset_key() click to toggle source
# File lib/rgovdata/service/dataset/dataset.rb, line 32
def dataset_key     ; options.dataset_key         ; end
Also aliased as: native_dataset_key
limit() click to toggle source

Returns the record limit currently imposed

# File lib/rgovdata/service/dataset/dataset.rb, line 35
def limit           ; options.limit               ; end
limit=(value) click to toggle source

Set the record limit to value

# File lib/rgovdata/service/dataset/dataset.rb, line 37
def limit=(value)
  options.limit = value
end
meta_attributes() click to toggle source

Returns array of attributes that describe the specific entity

> overrides RGovData::Dn.meta_attributes

# File lib/rgovdata/service/dataset/dataset.rb, line 43
def meta_attributes
  [:id,:realm,:service_key,:dataset_key]
end
native_dataset_key()

Returns the native dataset key

Alias for: dataset_key
native_instance(reload = false) click to toggle source

Returns the native dataset instance If reload is true, it re-initializes

# File lib/rgovdata/service/dataset/dataset.rb, line 52
def native_instance(reload = false)
  @native_instance = if reload
    load_instance
  else
    @native_instance || load_instance
  end
end
realm() click to toggle source

attribute accessors

# File lib/rgovdata/service/dataset/dataset.rb, line 30
def realm           ; service.realm               ; end
records(reload = false) click to toggle source

Returns the records If reload is true, it re-initializes and re-runs the query

# File lib/rgovdata/service/dataset/dataset.rb, line 62
def records(reload = false)
  @records = if reload
    load_records
  else
    @records || load_records
  end
end
service_key() click to toggle source
# File lib/rgovdata/service/dataset/dataset.rb, line 31
def service_key     ; service.service_key         ; end
uri() click to toggle source
# File lib/rgovdata/service/dataset/dataset.rb, line 33
def uri             ; service.uri                 ; end

Protected Instance Methods

load_instance() click to toggle source

Loads the native dataset

> override this in specific dataset classes as required

# File lib/rgovdata/service/dataset/dataset.rb, line 78
def load_instance
  nil
end
load_records() click to toggle source

Loads the native record set

> override this in specific dataset classes as required

# File lib/rgovdata/service/dataset/dataset.rb, line 85
def load_records
  nil
end