Class: SirTrevorRails::Blocks::BrowseGroupCategoriesBlock

Inherits:
SirTrevorRails::Block show all
Includes:
Displayable
Defined in:
app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb

Overview

Browese Group Categories

Constant Summary

Constants inherited from SirTrevorRails::Block

SirTrevorRails::Block::DEFAULT_FORMAT

Instance Attribute Summary

Attributes inherited from SirTrevorRails::Block

#parent, #type

Instance Method Summary collapse

Methods included from Displayable

#item_ids, #items, #ordered_items

Methods inherited from SirTrevorRails::Block

#as_json, block_class, block_class!, custom_block_types, #format, from_hash, #initialize, #to_partial_path, type_klass

Constructor Details

This class inherits a constructor from SirTrevorRails::Block

Instance Method Details

#display_item_counts?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb', line 10

def display_item_counts?
  send(:'display-item-counts') == 'true'
end

#groupsObject



14
15
16
17
18
# File 'app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb', line 14

def groups
  @groups ||= parent.exhibit.groups.published.where(slug: item_ids).sort do |a, b|
    ordered_items.index(a.slug) <=> ordered_items.index(b.slug)
  end
end

#groups?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb', line 20

def groups?
  !groups.empty?
end