Class: Remotable::NullRemote
- Inherits:
-
Object
- Object
- Remotable::NullRemote
- Defined in:
- lib/remotable/null_remote.rb
Class Method Summary collapse
-
.find_by(remote_attr, value) ⇒ Object
This is always invoked via class#find_remote_resource_by by class#fetch_by.
-
.find_by_for_local(local_record, remote_key, fetch_value) ⇒ Object
This is always invoked by instance#fetch_remote_resource.
- .new_resource ⇒ Object
Instance Method Summary collapse
-
#[]=(attribute, value) ⇒ Object
NullRemote needs to receive setter messages and swallow them.
- #destroy ⇒ Object
- #errors ⇒ Object
- #key?(attribute) ⇒ Boolean
- #save ⇒ Object
Class Method Details
.find_by(remote_attr, value) ⇒ Object
This is always invoked via class#find_remote_resource_by by class#fetch_by. It gives the remote model an opportunity to discover a remote object that doesn’t have a local counterpart. NullRemote should never discover something that doesn’t exist locally.
19 20 21 |
# File 'lib/remotable/null_remote.rb', line 19 def find_by(remote_attr, value) nil end |
.find_by_for_local(local_record, remote_key, fetch_value) ⇒ Object
This is always invoked by instance#fetch_remote_resource. It expects to find a remote counterpart for a local resource. It should always return a NullRemote object that doesn’t alter the behavior of a normal model at all.
10 11 12 |
# File 'lib/remotable/null_remote.rb', line 10 def find_by_for_local(local_record, remote_key, fetch_value) new end |
.new_resource ⇒ Object
23 24 25 |
# File 'lib/remotable/null_remote.rb', line 23 def new_resource new end |
Instance Method Details
#[]=(attribute, value) ⇒ Object
NullRemote needs to receive setter messages and swallow them. It doesn’t need to respond to getter messages since it has nothing to say.
34 35 |
# File 'lib/remotable/null_remote.rb', line 34 def []=(attribute, value) end |
#destroy ⇒ Object
49 50 51 |
# File 'lib/remotable/null_remote.rb', line 49 def destroy true end |
#errors ⇒ Object
45 46 47 |
# File 'lib/remotable/null_remote.rb', line 45 def errors {} end |
#key?(attribute) ⇒ Boolean
37 38 39 |
# File 'lib/remotable/null_remote.rb', line 37 def key?(attribute) false end |
#save ⇒ Object
41 42 43 |
# File 'lib/remotable/null_remote.rb', line 41 def save true end |