Commit 247f606d authored by Ohad Dahan's avatar Ohad Dahan

Add Nativepluck.validate_args to select if we validate argument types or not

parent b859e16c
......@@ -16,17 +16,24 @@ require "nativepluck/version"
module Nativepluck
@nativepluck_init = false
@validate_args = false
@arguments_validator = {
offset: Integer,
limit: Integer,
order: Hash,
group: Array,
group: Array
}
class << self
attr_accessor :nativepluck_type_map_for_results, :nativepluck_type_map_for_queries
attr_accessor :original_type_map_for_results, :original_type_map_for_queries
attr_accessor :nativepluck_init, :arguments_validator
attr_accessor :validate_args
end
def self.set_validate_args(selection)
raise ArgumentError.new("Input should be true/false and not #{selection.class}") if !(selection.is_a?(TrueClass) || selection.is_a?(FalseClass))
Nativepluck.validate_args = selection
end
def self.included(klass)
......@@ -84,7 +91,7 @@ module Nativepluck
module ClassMethods
def nativepluck(*columns, **opts)
raise ArgumentError.new('No columns to pluck were provided') if columns.size == 0
Nativepluck.validate_nativepluck_args(**opts)
Nativepluck.validate_nativepluck_args(**opts) if Nativepluck.validate_args
begin
Nativepluck.set_pg_native_casters
sql = "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment