class Organism::CellsGenerator

Public Instance Methods

create_cells() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 9
def create_cells
  cells.each do |cell|
    create_cell(cell)
    create_cell_spec(cell) if %w[cell form list table].include?(cell)

    next if cell == 'list'
    next if cell == 'table'

    create_cell_view(cell)

    next unless cell == 'cell'
    next unless cells.include?('list')

    create_cell_view(cell, 'list')
  end
end

Private Instance Methods

base_cell_class() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 85
def base_cell_class
  'ApplicationCell'
end
cell?() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 81
def cell?
  list? || table? || show?
end
cell_actions() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 53
def cell_actions
  [].tap do |array|
    array << 'list' if list?
    array << 'show' if show?
  end
end
cell_component_style() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 104
def cell_component_style
  singular_table_name.gsub('_', '-')
end
cells() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 60
def cells
  [].tap do |array|
    array << 'form' if form?
    array << 'cell' if cell?
    array << 'list' if list?
    array << 'table' if table?
  end
end
collections() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 93
def collections
  options[:collections]
end
create_cell(type) click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 35
def create_cell(type)
  template(
    "#{type}/cell.rb",
    File.join('app/cells', singular_file_path, "#{type}.rb")
  )
end
create_cell_spec(type) click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 42
def create_cell_spec(type)
  template(
    "#{type}/spec.rb",
    File.join('spec/cells', singular_file_path, "#{type}_spec.rb")
  )
end
create_cell_view(type, view = 'show') click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 28
def create_cell_view(type, view = 'show')
  template(
    "#{type}/#{view}.rb",
    File.join('app/cells', singular_file_path, "#{type}/#{view}.erb")
  )
end
form?() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 69
def form?
  new? || edit?
end
form_helper_class() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 89
def form_helper_class
  'Forms'
end
list?() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 73
def list?
  collections.include?('list')
end
list_component_style() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 108
def list_component_style
  "#{cell_component_style}--list"
end
nested_namespace(&block) click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 97
def nested_namespace(&block)
  content = capture(&block)
  content = wrap_model(indent(content))
  content = nest_content(content)
  concat("#{content}\n")
end
singular_file_path() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 49
def singular_file_path
  model_class_path.join('/')
end
table?() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 77
def table?
  collections.include?('table')
end
table_component_style() click to toggle source
# File lib/organism/generators/cells/cells_generator.rb, line 112
def table_component_style
  "#{cell_component_style}--table"
end