Sha256: c40ea516ec4502e6b99d84be00c828e30ecebcdcc83c0f5ed05743890c303815
Contents?: true
Size: 940 Bytes
Versions: 6
Compression:
Stored size: 940 Bytes
Contents
# Proxy makes different kind of data accessible # If href is present it also alows loading/reloading class LHS::Proxy autoload :Accessors, 'lhs/concerns/proxy/accessors' autoload :Create, 'lhs/concerns/proxy/create' autoload :Errors, 'lhs/concerns/proxy/errors' autoload :Link, 'lhs/concerns/proxy/link' include Accessors include Create include Errors include Link # prevent clashing with attributes of underlying data attr_accessor :_data, :_loaded def initialize(data) self._data = data self._loaded = false end def record _data.class end def load!(options = nil) return self if _loaded reload!(options) end def reload!(options = nil) raise 'No href found' unless _data.href options = {} if options.blank? data = _data.class.request(options.merge(url: _data.href, method: :get)) _data.merge_raw!(data) self._loaded = true self end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
lhs-12.2.0 | lib/lhs/proxy.rb |
lhs-12.1.0 | lib/lhs/proxy.rb |
lhs-12.0.3 | lib/lhs/proxy.rb |
lhs-12.0.2 | lib/lhs/proxy.rb |
lhs-12.0.1 | lib/lhs/proxy.rb |
lhs-12.0.0 | lib/lhs/proxy.rb |