Class: Resync::Augmented
- Inherits:
-
Object
- Object
- Resync::Augmented
- Defined in:
- lib/resync/client/resync_extensions.rb
Overview
Injects a Client that subclasses can use to fetch resources and links
Instance Attribute Summary collapse
-
#client ⇒ Client
The injected Client.
Instance Method Summary collapse
-
#links=(value) ⇒ Object
Adds a
:clientmethod to each link, delegating to #client.
Instance Attribute Details
#client ⇒ Client
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/resync/client/resync_extensions.rb', line 17 class Augmented attr_writer :client def client @client ||= Client.new end alias_method :base_links=, :links= private :base_links= # Adds a +:client+ method to each link, delegating # to {#client} def links=(value) self.base_links = value self.base_links = value parent = self links.each do |l| l.define_singleton_method(:client) do parent.client end end end end |
Instance Method Details
#links=(value) ⇒ Object
Adds a :client method to each link, delegating
to #client
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/resync/client/resync_extensions.rb', line 29 def links=(value) self.base_links = value self.base_links = value parent = self links.each do |l| l.define_singleton_method(:client) do parent.client end end end |