Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Give up on .try
Browse files Browse the repository at this point in the history
Fixes #56
  • Loading branch information
jcs committed Jun 28, 2018
1 parent 663da61 commit d37bf31
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/cipher.rb
Expand Up @@ -59,7 +59,8 @@ def migrate_data!

self.name = js.delete("Name")
self.notes = js.delete("Notes")
self.fields = js.delete("Fields").try(:to_json)
f = js.delete("Fields")
self.fields = f ? f.to_json : nil

if self.type == TYPE_LOGIN
js["Uris"] = [
Expand Down
6 changes: 3 additions & 3 deletions lib/dbmodel.rb
Expand Up @@ -39,7 +39,7 @@ def all

# transform ruby data into sql
def cast_data_for_column(data, col)
if !@columns.try(:any?)
if !@columns || !@columns.any?
raise "need to fetch columns but in a query"
end

Expand All @@ -62,7 +62,7 @@ def clear_column_cache!
end

def fetch_columns
return if @columns.try(:any?)
return if (@columns && @columns.any?)

@columns = {}

Expand Down Expand Up @@ -145,7 +145,7 @@ def set_table_name(table)

# transform database data into ruby
def uncast_data_from_column(data, col)
if !@columns.try(:any?)
if !@columns || !@columns.any?
raise "need to fetch columns but in a query"
end

Expand Down
4 changes: 0 additions & 4 deletions lib/helper.rb
Expand Up @@ -32,10 +32,6 @@ def blank?
def present?
false
end

def try(*a, &b)
nil
end
end

class String
Expand Down

0 comments on commit d37bf31

Please sign in to comment.