Module: Cable::ActsAsCable::ClassMethods

Defined in:
lib/cable/acts_as_cable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_cable(reflection_options = {}) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cable/acts_as_cable.rb', line 13

def acts_as_cable( reflection_options = {} )
  send :include, InstanceMethods
  send :include, ActionView::Helpers::TextHelper
  
  with_modules = []
  with_modules << reflection_options.delete(:with) if reflection_options.has_key?(:with)
  with_modules.flatten!
  
  has_one :menu, reflection_options.merge( :as => :cable_menuable )
  has_many :blocks, :as => :resource if with_modules.include? :blocks
  accepts_nested_attributes_for :menu
  
  self.cattr_accessor :default_template
  self.default_template = "default"
  
  yield self if block_given?
end

#template(template_name) ⇒ Object



31
32
33
# File 'lib/cable/acts_as_cable.rb', line 31

def template( template_name )
  self.default_template = (Cable.templates.include?( template_name.to_s )) ? template_name.to_s : :default.to_s
end