Sha256: 72f5c3030d8776ff2679df0b2b0348c0c3098926e25fce77fe22d6210751d399

Contents?: true

Size: 723 Bytes

Versions: 8

Compression:

Stored size: 723 Bytes

Contents

module CiviCrm
  module Actions
    module List
      module ClassMethods
        def all(params = {})
          params.merge!('entity' => entity_class_name, 'action' => 'get')
          response = CiviCrm::Client.request(:get, params)
          Resource.build_from(response, params)
        end

        def count
          all.count
        end

        def find_by(params={})
          all(params).first
        end

        def find_by!(params={})
          find_by(params) or raise Errors::NotFound.new
        end

        def first
          all.first
        end

        def last
          all.last
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
civicrm-1.3.7 lib/civicrm/actions/list.rb
civicrm-1.3.6 lib/civicrm/actions/list.rb
civicrm-1.3.5 lib/civicrm/actions/list.rb
civicrm-1.3.4 lib/civicrm/actions/list.rb
civicrm-1.3.3 lib/civicrm/actions/list.rb
civicrm-1.3.2 lib/civicrm/actions/list.rb
civicrm-1.3.1 lib/civicrm/actions/list.rb
civicrm-1.2.5 lib/civicrm/actions/list.rb