Module: BestInPlace::DisplayMethods
- Extended by:
- DisplayMethods
- Included in:
- DisplayMethods
- Defined in:
- lib/best_in_place/display_methods.rb
Defined Under Namespace
Classes: Renderer
Constant Summary collapse
- @@table =
Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }
Instance Method Summary collapse
- #add_helper_method(klass, attr, helper_method, helper_options = nil) ⇒ Object
- #add_helper_proc(klass, attr, helper_proc) ⇒ Object
- #add_model_method(klass, attr, display_as) ⇒ Object
- #lookup(klass, attr) ⇒ Object
Instance Method Details
#add_helper_method(klass, attr, helper_method, helper_options = nil) ⇒ Object
36 37 38 |
# File 'lib/best_in_place/display_methods.rb', line 36 def add_helper_method(klass, attr, helper_method, = nil) @@table[klass.to_s][attr.to_s] = Renderer.new :method => helper_method.to_sym, :type => :helper, :attr => attr, :helper_options => end |
#add_helper_proc(klass, attr, helper_proc) ⇒ Object
40 41 42 |
# File 'lib/best_in_place/display_methods.rb', line 40 def add_helper_proc(klass, attr, helper_proc) @@table[klass.to_s][attr.to_s] = Renderer.new :type => :proc, :attr => attr, :proc => helper_proc end |
#add_model_method(klass, attr, display_as) ⇒ Object
32 33 34 |
# File 'lib/best_in_place/display_methods.rb', line 32 def add_model_method(klass, attr, display_as) @@table[klass.to_s][attr.to_s] = Renderer.new :method => display_as.to_sym, :type => :model end |
#lookup(klass, attr) ⇒ Object
27 28 29 30 |
# File 'lib/best_in_place/display_methods.rb', line 27 def lookup(klass, attr) foo = @@table[klass.to_s][attr.to_s] foo == {} ? nil : foo end |