Module: Slices::HasSlices::ClassMethods

Defined in:
lib/slices/has_slices.rb

Instance Method Summary collapse

Instance Method Details

#has_slices(embed_name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/slices/has_slices.rb', line 10

def has_slices(embed_name)
  embeds_many embed_name, class_name: 'Slice', validate: false
  accepts_nested_attributes_for embed_name, allow_destroy: true

  class_attribute :slice_embeds if self == Page
  if slice_embeds.nil?
    self.slice_embeds = [embed_name]
  else
    self.slice_embeds = slice_embeds + [embed_name]
  end

  class_eval "    def ordered_\#{embed_name}             # def orderd_slices\n      \#{embed_name}.ascending(:position)  #   slices.ascending(:position)\n    end                                   # end\n  RUBY\nend\n", __FILE__, __LINE__ + 1