Class: DHS::Proxy
- Inherits:
-
Object
- Object
- DHS::Proxy
- Defined in:
- lib/dhs/proxy.rb,
lib/dhs/concerns/proxy/link.rb,
lib/dhs/concerns/proxy/create.rb,
lib/dhs/concerns/proxy/problems.rb,
lib/dhs/concerns/proxy/accessors.rb
Overview
Proxy makes different kind of data accessible If href is present it also alows loading/reloading
Direct Known Subclasses
Defined Under Namespace
Modules: Accessors, Create, Link, Problems
Constant Summary
Constants included from Accessors
Accessors::BLACKLISTED_KEYWORDS
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!(options = nil) ⇒ Object
- #record ⇒ Object
- #reload!(options = nil) ⇒ Object
Methods included from Create
Methods included from Accessors
Constructor Details
#initialize(data) ⇒ Proxy
Returns a new instance of Proxy.
25 26 27 28 |
# File 'lib/dhs/proxy.rb', line 25 def initialize(data) self._data = data self._loaded = false end |
Instance Attribute Details
#_data ⇒ Object
prevent clashing with attributes of underlying data
21 22 23 |
# File 'lib/dhs/proxy.rb', line 21 def _data @_data end |
#_loaded ⇒ Object
prevent clashing with attributes of underlying data
21 22 23 |
# File 'lib/dhs/proxy.rb', line 21 def _loaded @_loaded end |
Instance Method Details
#load!(options = nil) ⇒ Object
34 35 36 37 |
# File 'lib/dhs/proxy.rb', line 34 def load!( = nil) return self if _loaded reload!() end |
#record ⇒ Object
30 31 32 |
# File 'lib/dhs/proxy.rb', line 30 def record _data.class end |
#reload!(options = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dhs/proxy.rb', line 39 def reload!( = nil) = {} if .blank? data = _data.class.request( .merge(method: :get).merge() ) _data.merge_raw!(data.unwrap(:item_key)) self._loaded = true return becomes(_record) if _record self end |