Sha256: 7e1d878687de161b724bdbf98003ef31c3fe514a8dcefebb8eca611dba7ee37d

Contents?: true

Size: 701 Bytes

Versions: 54

Compression:

Stored size: 701 Bytes

Contents

module ZTK::DSL::Core::Actions

  # @author Zachary Patten <zachary AT jovelabs DOT com>
  # @api private
  module Find

    def self.included(base)
      base.class_eval do
        base.send(:extend, ZTK::DSL::Core::Actions::Find::ClassMethods)
      end
    end

    # @author Zachary Patten <zachary AT jovelabs DOT com>
    module ClassMethods

      def all
        dataset
      end

      def find(*args)
        ids = [args].flatten
        all.select{ |data| ids.include?(data.id) }
      end

      def first(*args)
        if args.count == 0
          all.first
        else
          find(*args).first
        end
      end

      def count
        all.count
      end

    end

  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
ztk-3.1.0 lib/ztk/dsl/core/actions/find.rb
ztk-3.0.4 lib/ztk/dsl/core/actions/find.rb
ztk-3.0.3 lib/ztk/dsl/core/actions/find.rb
ztk-3.0.2 lib/ztk/dsl/core/actions/find.rb
ztk-3.0.1 lib/ztk/dsl/core/actions/find.rb
ztk-3.0.0 lib/ztk/dsl/core/actions/find.rb
ztk-2.4.2 lib/ztk/dsl/core/actions/find.rb
ztk-2.4.1 lib/ztk/dsl/core/actions/find.rb
ztk-2.4.0 lib/ztk/dsl/core/actions/find.rb
ztk-2.3.1 lib/ztk/dsl/core/actions/find.rb
ztk-2.3.0 lib/ztk/dsl/core/actions/find.rb
ztk-2.2.0 lib/ztk/dsl/core/actions/find.rb
ztk-2.1.1 lib/ztk/dsl/core/actions/find.rb
ztk-2.1.0 lib/ztk/dsl/core/actions/find.rb
ztk-2.0.1 lib/ztk/dsl/core/actions/find.rb
ztk-2.0.0 lib/ztk/dsl/core/actions/find.rb
ztk-1.19.2 lib/ztk/dsl/core/actions/find.rb
ztk-1.19.1 lib/ztk/dsl/core/actions/find.rb
ztk-1.19.0 lib/ztk/dsl/core/actions/find.rb
ztk-1.18.5 lib/ztk/dsl/core/actions/find.rb