Module: PlyushkinExtensions
- Defined in:
- lib/plyushkin/core_ext/plyushkin_extensions.rb
Instance Method Summary collapse
- #load_plyushkin ⇒ Object
- #plyushkin ⇒ Object
- #reload(options = nil) ⇒ Object
- #save_plyushkin ⇒ Object
Instance Method Details
#load_plyushkin ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/plyushkin/core_ext/plyushkin_extensions.rb', line 11 def load_plyushkin self.class.plyushkin_model.callbacks.each do |name,callbacks| callbacks.each do |callback, handler| plyushkin.register_callback(name, callback) do (handler && handler.is_a?(Symbol)) ? send(handler) : handler.call end end end self.class.plyushkin_model.registered_types.each do |name, type| filter = self.class.plyushkin_model.filters[name] || self.class.plyushkin_model.hoarding_filter plyushkin.register_filter(name) do |value| (filter && filter.is_a?(Symbol)) ? send(filter, value) : filter.call(value) end if filter end plyushkin.load(id) end |
#plyushkin ⇒ Object
7 8 9 |
# File 'lib/plyushkin/core_ext/plyushkin_extensions.rb', line 7 def plyushkin @plyushkin ||= Plyushkin::Persistence.new(self.class.plyushkin_model) end |
#reload(options = nil) ⇒ Object
2 3 4 5 |
# File 'lib/plyushkin/core_ext/plyushkin_extensions.rb', line 2 def reload(=nil) plyushkin.load(id) super end |
#save_plyushkin ⇒ Object
30 31 32 |
# File 'lib/plyushkin/core_ext/plyushkin_extensions.rb', line 30 def save_plyushkin plyushkin.save(id) end |