Skip to content

Commit

Permalink
Removed named parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Neira committed Aug 20, 2019
1 parent 60271b9 commit ced344e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions lib/rasti/db/type_converters/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ def to_db(db, collection_name, attribute_name, value)
to_db_mapping = to_db_mapping_for db, collection_name

if to_db_mapping.key? attribute_name
to_db_mapping[attribute_name][:converter].to_db value: value,
sub_type: to_db_mapping[attribute_name][:sub_type]
to_db_mapping[attribute_name][:converter].to_db value, to_db_mapping[attribute_name][:sub_type]
else
value
end
end

def from_db(object)
if from_db_mapping.key? object.class
from_db_mapping[object.class].from_db object: object
from_db_mapping[object.class].from_db object
else
object
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rasti/db/type_converters/postgres_types/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def column_type_regex
/^([a-z]+)\[\]$/
end

def to_db(value:, sub_type:)
def to_db(value, sub_type)
array = sub_type == 'hstore' ? value.map { |v| Sequel.hstore v } : value
Sequel.pg_array array
end
Expand All @@ -19,7 +19,7 @@ def db_class
Sequel::Postgres::PGArray
end

def from_db(object:)
def from_db(object)
object.to_a
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rasti/db/type_converters/postgres_types/hstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def column_type_regex
/^hstore$/
end

def to_db(value:, sub_type:)
def to_db(value, sub_type)
Sequel.hstore value
end

def db_class
Sequel::Postgres::HStore
end

def from_db(object:)
def from_db(object)
object.to_h
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rasti/db/type_converters/postgres_types/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def column_type_regex
/^json$/
end

def to_db(value:, sub_type:)
def to_db(value, sub_type)
Sequel.pg_json value
end

def db_class
Sequel::Postgres::JSONOp
end

def from_db(object:)
def from_db(object)
object.value
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rasti/db/type_converters/postgres_types/jsonb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def column_type_regex
/^jsonb$/
end

def to_db(value:, sub_type:)
def to_db(value, sub_type)
Sequel.pg_jsonb value
end

def db_class
Sequel::Postgres::JSONBHash
end

def from_db(object:)
def from_db(object)
object.to_h
end

Expand Down

0 comments on commit ced344e

Please sign in to comment.