Class: SWD::Resource
- Inherits:
-
Object
- Object
- SWD::Resource
- Includes:
- 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.
8 9 10 11 12 13 14 |
# File 'lib/swd/resource.rb', line 8 def initialize(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
16 17 18 19 20 21 22 |
# File 'lib/swd/resource.rb', line 16 def discover!( = {}) SWD.cache.fetch(cache_key, ) do handle_response do SWD.http_client.get_content endpoint.to_s end end end |
#endpoint ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/swd/resource.rb', line 24 def endpoint SWD.url_builder.build [nil, host, nil, path, { :principal => principal, :service => service }.to_query, nil] rescue URI::Error => e raise Exception.new(e.) end |