Class: W3cApi::Hal
Constant Summary collapse
- API_URL =
"https://api.w3.org/"
Instance Method Summary collapse
- #client ⇒ Object
-
#configure_rate_limiting(options = {}) ⇒ Object
Set rate limiting options.
-
#disable_rate_limiting ⇒ Object
Disable rate limiting.
-
#enable_rate_limiting ⇒ Object
Enable rate limiting.
-
#initialize ⇒ Hal
constructor
A new instance of Hal.
-
#rate_limiting_options ⇒ Object
Configure rate limiting options.
- #register ⇒ Object
- #reset_register ⇒ Object
Constructor Details
#initialize ⇒ Hal
Returns a new instance of Hal.
46 47 48 |
# File 'lib/w3c_api/hal.rb', line 46 def initialize # Don't call setup here - it will be called when register is first accessed end |
Instance Method Details
#client ⇒ Object
50 51 52 53 54 55 |
# File 'lib/w3c_api/hal.rb', line 50 def client @client ||= Lutaml::Hal::Client.new( api_url: API_URL, rate_limiting: , ) end |
#configure_rate_limiting(options = {}) ⇒ Object
Set rate limiting options
69 70 71 72 73 |
# File 'lib/w3c_api/hal.rb', line 69 def configure_rate_limiting( = {}) @rate_limiting_options = .merge() # Reset client to pick up new options @client = nil end |
#disable_rate_limiting ⇒ Object
Disable rate limiting
76 77 78 |
# File 'lib/w3c_api/hal.rb', line 76 def disable_rate_limiting configure_rate_limiting(enabled: false) end |
#enable_rate_limiting ⇒ Object
Enable rate limiting
81 82 83 |
# File 'lib/w3c_api/hal.rb', line 81 def enable_rate_limiting configure_rate_limiting(enabled: true) end |
#rate_limiting_options ⇒ Object
Configure rate limiting options
58 59 60 61 62 63 64 65 66 |
# File 'lib/w3c_api/hal.rb', line 58 def @rate_limiting_options ||= { enabled: true, max_retries: 5, base_delay: 0.1, max_delay: 10.0, backoff_factor: 1.5, } end |
#register ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/w3c_api/hal.rb', line 85 def register return @register if @register @register = Lutaml::Hal::ModelRegister.new(name: :w3c_api, client: client) Lutaml::Hal::GlobalRegister.instance.register(:w3c_api, @register) # Re-run setup to register all endpoints with the new register setup @register end |
#reset_register ⇒ Object
97 98 99 |
# File 'lib/w3c_api/hal.rb', line 97 def reset_register @register = nil end |