Module: BestInPlaceMongoid::DisplayMethods

Extended by:
DisplayMethods
Included in:
DisplayMethods
Defined in:
lib/best_in_place_mongoid/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

Instance Method Details

#add_helper_method(klass, attr, helper_method, helper_options = nil) ⇒ Object



34
35
36
# File 'lib/best_in_place_mongoid/display_methods.rb', line 34

def add_helper_method(klass, attr, helper_method, helper_options = nil)
  @@table[klass.to_s][attr.to_s] = Renderer.new :method => helper_method.to_sym, :type => :helper, :attr => attr, :helper_options => helper_options
end

#add_model_method(klass, attr, display_as) ⇒ Object



30
31
32
# File 'lib/best_in_place_mongoid/display_methods.rb', line 30

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



25
26
27
28
# File 'lib/best_in_place_mongoid/display_methods.rb', line 25

def lookup(klass, attr)
  foo = @@table[klass.to_s][attr.to_s]
  foo == {} ? nil : foo
end