Skip to content

Commit

Permalink
refactor: Migrate add verb into its own DSL file
Browse files Browse the repository at this point in the history
The `case object add` was previously located into the
`PartialUpdateObject.scala` file. However, we need to use it for the
upcoming AB Test implementation.

This commit moves the entire `case object add` into its own
`AddDsl.scala` file, like what we already have for existing common verb
such as `get` (`GetDsl.scala`), `list` (`ListDsl.scala`), etc.
  • Loading branch information
aseure committed Jun 20, 2018
1 parent 559d25f commit b6b6aff
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/scala/algolia/AlgoliaDsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import scala.util.matching.Regex
trait AlgoliaDsl
extends Object //Just to have all trait DSL ordered `with`
with KeyDefinitionDsl
with AddDsl
with BatchDsl
with BrowseDsl
with ClearDsl
Expand Down
45 changes: 45 additions & 0 deletions src/main/scala/algolia/dsl/AddDsl.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Algolia
* http://www.algolia.com/
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package algolia.dsl

import algolia.definitions.{Add, AddKeyDefinition, PartialUpdateObjectOperationDefinition}
import algolia.objects.ApiKey
import org.json4s.Formats

trait AddDsl {

implicit val formats: Formats

case object add {

def value(value: String): PartialUpdateObjectOperationDefinition =
PartialUpdateObjectOperationDefinition(Add, value = Some(value))

def key(key: ApiKey) = AddKeyDefinition(key)

}

}
9 changes: 0 additions & 9 deletions src/main/scala/algolia/dsl/PartialUpdateObjectDsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ trait PartialUpdateObjectDsl {

}

case object add {

def value(value: String): PartialUpdateObjectOperationDefinition =
PartialUpdateObjectOperationDefinition(Add, value = Some(value))

def key(key: ApiKey) = AddKeyDefinition(key)

}

case object addUnique {

def value(value: String): PartialUpdateObjectOperationDefinition =
Expand Down

0 comments on commit b6b6aff

Please sign in to comment.