Sha256: 98bd7524740db254f8bae05f2a1a3f5a05f414bef624b880add81154ad5925fa

Contents?: true

Size: 573 Bytes

Versions: 10

Compression:

Stored size: 573 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

10 entries across 10 versions & 1 rubygems

Version Path
lhs-1.6.1 lib/lhs/proxy.rb
lhs-1.6.0 lib/lhs/proxy.rb
lhs-2.0.0 lib/lhs/proxy.rb
lhs-1.5.0 lib/lhs/proxy.rb
lhs-1.4.0 lib/lhs/proxy.rb
lhs-1.3.1 lib/lhs/proxy.rb
lhs-1.3.0 lib/lhs/proxy.rb
lhs-1.2.3 lib/lhs/proxy.rb
lhs-1.2.2 lib/lhs/proxy.rb
lhs-1.2.1 lib/lhs/proxy.rb