Class: SWD::Resource
- Inherits:
-
Object
- Object
- SWD::Resource
- Includes:
- AttrOptional, AttrRequired
- Defined in:
- lib/swd/resource.rb
Defined Under Namespace
Classes: Expired
Instance Method Summary collapse
- #discover!(cache_options = {}) ⇒ Object
- #endpoint ⇒ Object
-
#initialize(attributes = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(attributes = {}) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 13 14 15 |
# File 'lib/swd/resource.rb', line 9 def initialize(attributes = {}) (optional_attributes + required_attributes).each do |key| self.send "#{key}=", attributes[key] end @path ||= '/.well-known/simple-web-discovery' attr_missing! end |
Instance Method Details
#discover!(cache_options = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/swd/resource.rb', line 17 def discover!( = {}) SWD.cache.fetch(cache_key, ) do handle_response do SWD.http_client.get endpoint.to_s end end end |
#endpoint ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/swd/resource.rb', line 25 def endpoint SWD.url_builder.build [nil, host, port, path, { :principal => principal, :service => service }.to_query, nil] rescue URI::Error => e raise Exception.new(e.) end |