Module: Styler::Style::ClassMethods
- Defined in:
- lib/styler/style.rb
Instance Method Summary collapse
-
#association(*methods) ⇒ Object
Add all the methods that will call other model instances here.
- #delegate(*methods) ⇒ Object
- #delegate_to_controller(*methods) ⇒ Object
- #style_for(model) ⇒ Object
Instance Method Details
#association(*methods) ⇒ Object
Add all the methods that will call other model instances here. As there are no collection-styles, set up complicated stuff in :prepare
6 7 8 9 10 11 12 13 |
# File 'lib/styler/style.rb', line 6 def association(*methods) methods.each do |m| define_method(m) {|*args, &block| assoc = @model.send(m, *args, &block) ::Styler.new_style_for(assoc,serialize_to_hash.merge({@model.class.to_s.downcase.split('::').last => self})) } end end |
#delegate(*methods) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/styler/style.rb', line 15 def delegate(*methods) methods.each do |m| define_method(m) { |*args| @model.send(m, *args) } end end |
#delegate_to_controller(*methods) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/styler/style.rb', line 23 def delegate_to_controller(*methods) methods.each do |m| define_method(m) { |*args| @__controller.send(m, *args) } end end |