Class: LeanTesting::EntityHandler
- Inherits:
-
Object
- Object
- LeanTesting::EntityHandler
- Defined in:
- lib/BaseClass/EntityHandler.rb
Direct Known Subclasses
AttachmentsHandler, BugAttachmentsHandler, BugCommentsHandler, BugsHandler, PlatformBrowserVersionsHandler, PlatformBrowsersHandler, PlatformDevicesHandler, PlatformHandler, PlatformOSHandler, PlatformOSVersionsHandler, PlatformTypeDevicesHandler, PlatformTypesHandler, ProjectBugPrioritySchemeHandler, ProjectBugReproducibilitySchemeHandler, ProjectBugSeveritySchemeHandler, ProjectBugStatusSchemeHandler, ProjectBugTypeSchemeHandler, ProjectBugsHandler, ProjectSectionsHandler, ProjectUsersHandler, ProjectVersionsHandler, ProjectsHandler, UserHandler, UserOrganizationsHandler
Instance Method Summary collapse
-
#all(filters = nil) ⇒ Object
Function definition for listing all entities.
-
#create(fields) ⇒ Object
Function definition for creating a new entity.
-
#delete(id) ⇒ Object
Function definition for deleting an existing entity.
-
#find(id) ⇒ Object
Function definition for retrieving an existing entity.
-
#initialize(origin) ⇒ EntityHandler
constructor
Constructs an EntityHandler instance.
-
#update(id, fields) ⇒ Object
Function definition for updating an existing entity.
Constructor Details
#initialize(origin) ⇒ EntityHandler
Constructs an EntityHandler instance
Keyword arguments: origin Client – Originating client reference
20 21 22 |
# File 'lib/BaseClass/EntityHandler.rb', line 20 def initialize(origin) @origin = origin # Reference to originating Client instance end |
Instance Method Details
#all(filters = nil) ⇒ Object
Function definition for listing all entities. Base function checks for invalid parameters.
Keyword arguments: filters Hash – (optional) Filters to apply to restrict listing. Currently supported: limit, page
Exceptions: SDKInvalidArgException if provided filters param is not a hash. SDKInvalidArgException if invalid filter value found in filters hash.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/BaseClass/EntityHandler.rb', line 52 def all(filters = nil) if !filters filters = {} end if !filters.is_a? Hash raise SDKInvalidArgException, '`filters` must be a hash' else filters.each do |k,| if !['include', 'limit', 'page'].include? k raise SDKInvalidArgException, 'unsupported ' + k + ' for `filters`' end end end end |
#create(fields) ⇒ Object
Function definition for creating a new entity. Base function checks for invalid parameters.
Keyword arguments: fields Hash – Non-empty hash consisting of entity data to send for adding
Exceptions: SDKInvalidArgException if provided fields param is not a hash. SDKInvalidArgException if provided fields param is empty.
34 35 36 37 38 39 40 |
# File 'lib/BaseClass/EntityHandler.rb', line 34 def create(fields) if !fields.is_a? Hash raise SDKInvalidArgException, '`fields` must be a hash' elsif fields.length.zero? raise SDKInvalidArgException, '`fields` must be non-empty' end end |
#delete(id) ⇒ Object
Function definition for deleting an existing entity. Base function checks for invalid parameters.
Keyword arguments: id Fixnum – ID field of entity to delete in the entity collection
Exceptions: SDKInvalidArgException if provided id param is not an integer.
93 94 95 96 97 |
# File 'lib/BaseClass/EntityHandler.rb', line 93 def delete(id) if !id.is_a? Fixnum raise SDKInvalidArgException, '`id` must be of type Fixnum' end end |
#find(id) ⇒ Object
Function definition for retrieving an existing entity. Base function checks for invalid parameters.
Keyword arguments: id Fixnum – ID field to look for in the entity collection
Exceptions: SDKInvalidArgException if provided id param is not an integer.
78 79 80 81 82 |
# File 'lib/BaseClass/EntityHandler.rb', line 78 def find(id) if !id.is_a? Fixnum raise SDKInvalidArgException, '`id` must be of type Fixnum' end end |
#update(id, fields) ⇒ Object
Function definition for updating an existing entity. Base function checks for invalid parameters.
Keyword arguments: id Fixnum – ID field of entity to update in the entity collection fields Hash – Non-empty dictionary consisting of entity data to send for update
Exceptions: SDKInvalidArgException if provided id param is not an integer. SDKInvalidArgException if provided fields param is not a hash. SDKInvalidArgException if provided fields param is empty.
111 112 113 114 115 116 117 118 119 |
# File 'lib/BaseClass/EntityHandler.rb', line 111 def update(id, fields) if !id.is_a? Fixnum raise SDKInvalidArgException, '`id` must be of type Fixnum' elsif !fields.is_a? Hash raise SDKInvalidArgException, '`fields` must be a hash' elsif fields.length.zero? raise SDKInvalidArgException, '`fields` must be non-empty' end end |