Sha256: d89be532c295682fd0703a02a5fca2d7ed2472fda60ee9e0465d8372aa2134ff

Contents?: true

Size: 568 Bytes

Versions: 16

Compression:

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

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lhs-3.3.6 lib/lhs/proxy.rb
lhs-3.3.5 lib/lhs/proxy.rb
lhs-3.3.3 lib/lhs/proxy.rb
lhs-3.3.2 lib/lhs/proxy.rb
lhs-3.3.1 lib/lhs/proxy.rb
lhs-3.3.0 lib/lhs/proxy.rb
lhs-3.2.0 lib/lhs/proxy.rb
lhs-3.1.3 lib/lhs/proxy.rb
lhs-3.1.1 lib/lhs/proxy.rb
lhs-3.1.0 lib/lhs/proxy.rb
lhs-3.0.5 lib/lhs/proxy.rb
lhs-3.0.4 lib/lhs/proxy.rb
lhs-3.0.3 lib/lhs/proxy.rb
lhs-3.0.2 lib/lhs/proxy.rb
lhs-3.0.1 lib/lhs/proxy.rb
lhs-3.0.0 lib/lhs/proxy.rb