Sha256: c2b5ea57a2d0cbfd09dd6110010e0db37f4d426ceca676bda0d6eb57a36baf60

Contents?: true

Size: 574 Bytes

Versions: 5

Compression:

Stored size: 574 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
    service = _data._root._service
    data = service.instance.request(url: _data.href, method: :get)
    _data.merge_raw!(data)
    self._loaded = true
    self
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lhs-2.0.5 lib/lhs/proxy.rb
lhs-2.0.4 lib/lhs/proxy.rb
lhs-2.0.3 lib/lhs/proxy.rb
lhs-2.0.2 lib/lhs/proxy.rb
lhs-2.0.1 lib/lhs/proxy.rb