Sha256: b71545a0f3111d0d054bdf44680360292c47230e3d1d20b53912f637049b331d
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
module Navi module Navigable module InstanceMethods def to_navigator(options={}) return navigator_instance if navigator_instance options.merge!(:navigable => self) Navi.navigator_class.new options end def to_navigator!(options={}) navigator = to_navigator(options) navigator.save navigator end private # Easily get the navigator instance based on the Navi.navigator setting # Uses own finder because upon destroy the polymorphic association seemed # to break. def navigator_instance @navigator_instance ||= Navi.navigator.to_s.classify.constantize.where( :navigable_id => self.id, :navigable_type => self.class.name ).first end def prepare_standalone_navigator! if navigator_instance set_navigator_label_to_self! set_navigator_url_to_hash! nullify_navigator_pointer_to_self! end end def set_navigator_label_to_self! navigator_instance.label = navigator_instance.label end def set_navigator_url_to_hash! navigator_instance.url = "#" end def nullify_navigator_pointer_to_self! navigator_instance.update_attributes( :navigable_id => nil, :navigable_type => nil ) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
navi-0.2.1 | lib/navi/navigable/instance_methods.rb |
navi-0.2.0 | lib/navi/navigable/instance_methods.rb |
navi-0.1.4 | lib/navi/navigable/instance_methods.rb |