Sha256: 30e8ce5fb29f874999ff5f75bd1af9aef2b01da7ff9f2d8f2b70b13cba50305b

Contents?: true

Size: 565 Bytes

Versions: 5

Compression:

Stored size: 565 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.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.2.2 lib/lhs/proxy.rb
lhs-2.2.1 lib/lhs/proxy.rb
lhs-2.2.0 lib/lhs/proxy.rb
lhs-2.1.1 lib/lhs/proxy.rb
lhs-2.1.0 lib/lhs/proxy.rb