Class: LHS::Proxy
- Inherits:
-
Object
- Object
- LHS::Proxy
- Defined in:
- lib/lhs/proxy.rb
Overview
Proxy makes different kind of data accessible If href is present it also alows loading/reloading
Direct Known Subclasses
Instance Attribute Summary collapse
-
#_data ⇒ Object
prevent clashing with attributes of underlying data.
-
#_loaded ⇒ Object
prevent clashing with attributes of underlying data.
Instance Method Summary collapse
-
#initialize(data) ⇒ Proxy
constructor
A new instance of Proxy.
- #load! ⇒ Object
- #reload! ⇒ Object
Constructor Details
#initialize(data) ⇒ Proxy
Returns a new instance of Proxy.
8 9 10 11 |
# File 'lib/lhs/proxy.rb', line 8 def initialize(data) self._data = data self._loaded = false end |
Instance Attribute Details
#_data ⇒ Object
prevent clashing with attributes of underlying data
6 7 8 |
# File 'lib/lhs/proxy.rb', line 6 def _data @_data end |
#_loaded ⇒ Object
prevent clashing with attributes of underlying data
6 7 8 |
# File 'lib/lhs/proxy.rb', line 6 def _loaded @_loaded end |
Instance Method Details
#load! ⇒ Object
13 14 15 16 |
# File 'lib/lhs/proxy.rb', line 13 def load! return self if _loaded reload! end |
#reload! ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/lhs/proxy.rb', line 18 def reload! raise 'No href found' unless _data.href data = _data.class.request(url: _data.href, method: :get) _data.merge_raw!(data) self._loaded = true self end |