Class: Machinist::AbstractAdapter
- Inherits:
-
Object
- Object
- Machinist::AbstractAdapter
- Defined in:
- lib/machinist/adapters/abstract.rb
Direct Known Subclasses
Class Method Summary collapse
-
.inherited(klass) ⇒ Object
:api: private.
-
.priority(num = nil) ⇒ Object
Use this to set the priority of your adapter If you have a very specific test to see if this adapter should be used in use_for_class? then the priority should be set at 1.0 but if it is ambigious, then it should be set low.
-
.save(obj) ⇒ Object
Put code to save the object in here.
-
.use_for_class?(obj) ⇒ Boolean
A test to see if this adapter should be used for the specified class.
Class Method Details
.inherited(klass) ⇒ Object
:api: private
4 5 6 |
# File 'lib/machinist/adapters/abstract.rb', line 4 def self.inherited(klass) Machinist.add_adapter klass end |
.priority(num = nil) ⇒ Object
Use this to set the priority of your adapter If you have a very specific test to see if this adapter should be used in use_for_class? then the priority should be set at 1.0 but if it is ambigious, then it should be set low.
A test for a plain ruby object will return true always for example, so the priority should be set lower to give the other adapters a chance to match :api: plugin
15 16 17 18 19 20 21 |
# File 'lib/machinist/adapters/abstract.rb', line 15 def self.priority(num = nil) if num @priority = num.to_f else @priority ||= 0.0 end end |
.save(obj) ⇒ Object
Put code to save the object in here. For PORO (plain old ruby objects) this can just be blank :api: overwritable
26 27 |
# File 'lib/machinist/adapters/abstract.rb', line 26 def self.save(obj) end |
.use_for_class?(obj) ⇒ Boolean
A test to see if this adapter should be used for the specified class. If the test is ambiguous, then it should be given a low priority :api: overwritable
32 33 34 |
# File 'lib/machinist/adapters/abstract.rb', line 32 def self.use_for_class?(obj) raise "Need to add a use_for_class? method in your #{self.class} adapter" end |