Sha256: 282fd5a3b43c99c1d923140c1dd39b7cfe59c1389865026e3c966960b132c400

Contents?: true

Size: 954 Bytes

Versions: 6

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

module Dsu
  module Support
    module EntryGroupViewable
      def view_entry_groups(times:, options: {})
        total_viewable_entry_groups = 0

        times.each do |time|
          view_entry_group(time: time, options: options) do
            total_viewable_entry_groups += 1
            puts
          end
        end

        yield total_viewable_entry_groups if block_given?
      end

      def view_entry_group(time:, options: {})
        return unless show_entry_group?(time: time, options: options)

        entry_group = Models::EntryGroup.load(time: time)
        Views::EntryGroup::Show.new(entry_group: entry_group).render

        yield if block_given?
      end

      private

      def show_entry_group?(time:, options:)
        Models::EntryGroup.exists?(time: time) || options[:include_all]
      end

      module_function :view_entry_group, :view_entry_groups, :show_entry_group?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dsu-1.2.1 lib/dsu/support/entry_group_viewable.rb
dsu-1.2.0 lib/dsu/support/entry_group_viewable.rb
dsu-1.1.2 lib/dsu/support/entry_group_viewable.rb
dsu-1.1.1 lib/dsu/support/entry_group_viewable.rb
dsu-1.1.0.alpha.2 lib/dsu/support/entry_group_viewable.rb
dsu-1.1.0.alpha.1 lib/dsu/support/entry_group_viewable.rb