class RGovData::Service
A Service
describes a specific service It encapsulates access to the underlying service implementation
Attributes
native_instance[R]
options[RW]
Public Class Methods
get_instance(options={})
click to toggle source
Returns the appropriate Service
class for the given uri and type +options may be a RGovData::ServiceListing
or a Hash If options
is a hash, it requires the following members: uri
type
credentialset
# File lib/rgovdata/service/service.rb, line 19 def get_instance(options={}) type = (options.class <= RGovData::ServiceListing) ? options.type : options[:type] service_class = "RGovData::#{type.to_s.capitalize}Service".constantize service_class.new(options) rescue # invalid or not a supported type nil end
new(options)
click to toggle source
new
requires +options may be a RGovData::ServiceListing
or a Hash If options
is a hash, it requires the following members: uri
type
transport
credentialset
# File lib/rgovdata/service/service.rb, line 35 def initialize(options) @options = if options.is_a?(Hash) OpenStruct.new(options) elsif options.class <= RGovData::ServiceListing options.dup # avoid circular refs else OpenStruct.new end end
Public Instance Methods
credentialset()
click to toggle source
# File lib/rgovdata/service/service.rb, line 51 def credentialset ; options.credentialset ; end
dataset_keys()
click to toggle source
datasets()
click to toggle source
find(id)
click to toggle source
Returns the first dataset matching key
# File lib/rgovdata/service/service.rb, line 87 def find(id) Array(get_dataset(id)).first end
Also aliased as: find_by_id
get_dataset(key)
click to toggle source
Returns the dataset(s) matching key
# File lib/rgovdata/service/service.rb, line 81 def get_dataset(key) return nil unless datasets && !datasets.empty? matches = datasets.select {|s| s.dataset_key =~ /#{key}/} matches.count == 1 ? matches.first : matches 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/service.rb, line 55 def meta_attributes [:id,:realm,:service_key,:uri,:type,:transport,:credentialset] end
realm()
click to toggle source
attribute accessors
# File lib/rgovdata/service/service.rb, line 46 def realm ; options.realm ; end
service_key()
click to toggle source
# File lib/rgovdata/service/service.rb, line 47 def service_key ; options.service_key ; end
transport()
click to toggle source
# File lib/rgovdata/service/service.rb, line 50 def transport ; options.transport ; end
type()
click to toggle source
# File lib/rgovdata/service/service.rb, line 49 def type ; options.type ; end
uri()
click to toggle source
# File lib/rgovdata/service/service.rb, line 48 def uri ; options.uri ; end