Sha256: 1385252a9e0f41d0290f3bac15e6cbd7beaddbe33d1887d897d01a7774ed7543

Contents?: true

Size: 937 Bytes

Versions: 24

Compression:

Stored size: 937 Bytes

Contents

module Toy
  module Lists
    extend ActiveSupport::Concern

    module ClassMethods
      def lists
        @lists ||= {}
      end

      def list?(key)
        lists.keys.include?(key.to_sym)
      end

      # @examples
      #   list :games                                   # assumes Game
      #   list :games, :dependent => true               # assumes Game
      #   list :active_games, Game                      # uses Game
      #   list :active_games, Game, :dependent => true  # uses Game
      #
      #   list :games do
      #     def active
      #       target.select { |t| t.active? }
      #     end
      #   end
      #
      #   module ActiveExtension
      #     def active
      #       target.select { |t| t.active? }
      #     end
      #   end
      #   list :games, :extensions => [ActiveExtension]
      def list(name, *args, &block)
        List.new(self, name, *args, &block)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
toystore-0.13.2 lib/toy/lists.rb
toystore-0.13.1 lib/toy/lists.rb
toystore-0.13.0 lib/toy/lists.rb
toystore-0.12.0 lib/toy/lists.rb
toystore-0.11.0 lib/toy/lists.rb
toystore-0.10.4 lib/toy/lists.rb
toystore-0.10.3 lib/toy/lists.rb
toystore-0.10.2 lib/toy/lists.rb
toystore-0.10.1 lib/toy/lists.rb
toystore-0.10.0 lib/toy/lists.rb
toystore-0.9.0 lib/toy/lists.rb
toystore-0.8.3 lib/toy/lists.rb
toystore-0.8.2 lib/toy/lists.rb
toystore-0.8.1 lib/toy/lists.rb
toystore-0.8.0 lib/toy/lists.rb
toystore-0.7.0 lib/toy/lists.rb
toystore-0.6.6 lib/toy/lists.rb
toystore-0.6.5 lib/toy/lists.rb
toystore-0.6.4 lib/toy/lists.rb
toystore-0.6.3 lib/toy/lists.rb