Class: BitCore::Tool

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/bit_core/tool.rb

Overview

A section of an application.

Instance Method Summary collapse

Instance Method Details

#add_module(title_or_module) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'app/models/bit_core/tool.rb', line 18

def add_module(title_or_module)
  if title_or_module.class == String
    content_modules.build(title: title_or_module, position: next_position)
  else
    title_or_module.tap do |m|
      m.tool = self
      m.position = next_position
    end
  end
end

#last_positionObject



29
30
31
# File 'app/models/bit_core/tool.rb', line 29

def last_position
  content_modules.order(:position).last.try(:position) || 0
end