Sha256: cfb1b19eefdd2240e8c39466746f4e820b0f3e8768e915c092803a8f3eef668e

Contents?: true

Size: 534 Bytes

Versions: 33

Compression:

Stored size: 534 Bytes

Contents

# Proxy makes different kind of data accessible
# If href is present it also alows loading/reloading
class LHS::Proxy

  # prevent clashing with attributes of underlying data
  attr_accessor :_data, :_loaded

  def initialize(data)
    self._data = data
    self._loaded = false
  end

  def load!
    return self if _loaded
    reload!
  end

  def reload!
    fail 'No href found' unless _data.href
    data = _data.class.request(url: _data.href, method: :get)
    _data.merge_raw!(data)
    self._loaded = true
    self
  end

end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
lhs-6.4.0 lib/lhs/proxy.rb
lhs-6.3.1 lib/lhs/proxy.rb
lhs-6.3.0 lib/lhs/proxy.rb
lhs-6.2.0 lib/lhs/proxy.rb
lhs-6.1.0 lib/lhs/proxy.rb
lhs-6.0.0 lib/lhs/proxy.rb
lhs-5.7.1 lib/lhs/proxy.rb
lhs-5.7.0 lib/lhs/proxy.rb
lhs-5.6.6 lib/lhs/proxy.rb
lhs-5.6.5 lib/lhs/proxy.rb
lhs-5.6.4 lib/lhs/proxy.rb
lhs-5.6.3 lib/lhs/proxy.rb
lhs-5.6.2 lib/lhs/proxy.rb
lhs-5.6.1 lib/lhs/proxy.rb
lhs-5.6.0 lib/lhs/proxy.rb
lhs-5.5.0 lib/lhs/proxy.rb
lhs-5.4.2 lib/lhs/proxy.rb
lhs-5.4.1 lib/lhs/proxy.rb
lhs-5.4.0 lib/lhs/proxy.rb
lhs-5.3.0 lib/lhs/proxy.rb