Class: RGovData::DataSet
- Inherits:
-
Object
- Object
- RGovData::DataSet
- Includes:
- Dn
- Defined in:
- lib/rgovdata/service/dataset/dataset.rb
Overview
This is the catalog class that describes a generic Service DataSet
Direct Known Subclasses
Instance Attribute Summary collapse
-
#native_service ⇒ Object
readonly
Returns the value of attribute native_service.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Class Method Summary collapse
Instance Method Summary collapse
-
#attribute_value(row, attribute) ⇒ Object
Returns the value of the named
attribute
from a recordsetrow
Purpose is to encapsulate differences in addressing attribute values. - #dataset_key ⇒ Object (also: #native_dataset_key)
-
#initialize(options, service) ⇒ DataSet
constructor
A new instance of DataSet.
-
#limit ⇒ Object
Returns the record limit currently imposed.
-
#limit=(value) ⇒ Object
Set the record limit to
value
. -
#meta_attributes ⇒ Object
Returns array of attributes that describe the specific entity => overrides RGovData::Dn.meta_attributes.
-
#native_instance(reload = false) ⇒ Object
Returns the native dataset instance If
reload
is true, it re-initializes. -
#realm ⇒ Object
attribute accessors.
-
#records(reload = false) ⇒ Object
Returns the records If
reload
is true, it re-initializes and re-runs the query. - #service_key ⇒ Object
- #uri ⇒ Object
Methods included from Dn
#attributes, #id, #initialization_hash, #to_param, #to_s
Constructor Details
#initialize(options, service) ⇒ DataSet
Returns a new instance of DataSet.
19 20 21 22 23 24 25 26 27 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 19 def initialize(,service) @options = if .is_a?(Hash) OpenStruct.new() else OpenStruct.new end @service = service.dup # avoid circular dependencies @native_service = @service.try(:native_instance) end |
Instance Attribute Details
#native_service ⇒ Object (readonly)
Returns the value of attribute native_service.
6 7 8 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 6 def native_service @native_service end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 4 def @options end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
5 6 7 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 5 def service @service end |
Class Method Details
.load_datasets(service) ⇒ Object
9 10 11 12 13 14 15 16 |
# 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 |
Instance Method Details
#attribute_value(row, attribute) ⇒ Object
Returns the value of the named attribute
from a recordset row
Purpose is to encapsulate differences in addressing attribute values
72 73 74 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 72 def attribute_value(row,attribute) row.send(attribute) end |
#dataset_key ⇒ Object Also known as: native_dataset_key
32 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 32 def dataset_key ; .dataset_key ; end |
#limit ⇒ Object
Returns the record limit currently imposed
35 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 35 def limit ; .limit ; end |
#limit=(value) ⇒ Object
Set the record limit to value
37 38 39 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 37 def limit=(value) .limit = value end |
#meta_attributes ⇒ Object
Returns array of attributes that describe the specific entity
> overrides RGovData::Dn.meta_attributes
43 44 45 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 43 def [:id,:realm,:service_key,:dataset_key] end |
#native_instance(reload = false) ⇒ Object
Returns the native dataset instance If reload
is true, it re-initializes
52 53 54 55 56 57 58 |
# 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 ⇒ Object
attribute accessors
30 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 30 def realm ; service.realm ; end |
#records(reload = false) ⇒ Object
Returns the records If reload
is true, it re-initializes and re-runs the query
62 63 64 65 66 67 68 |
# 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 ⇒ Object
31 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 31 def service_key ; service.service_key ; end |
#uri ⇒ Object
33 |
# File 'lib/rgovdata/service/dataset/dataset.rb', line 33 def uri ; service.uri ; end |