Permalink
Browse files

Give up on .try

Fixes #56
  • Loading branch information...
jcs committed Jun 28, 2018
1 parent 663da61 commit d37bf3182805b8bde1e21b2d41220d769cbf1bd5
Showing with 5 additions and 8 deletions.
  1. +2 −1 lib/cipher.rb
  2. +3 −3 lib/dbmodel.rb
  3. +0 −4 lib/helper.rb
View
@@ -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"] = [
View
@@ -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
@@ -62,7 +62,7 @@ def clear_column_cache!
end
def fetch_columns
return if @columns.try(:any?)
return if (@columns && @columns.any?)
@columns = {}
@@ -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
View
@@ -32,10 +32,6 @@ def blank?
def present?
false
end
def try(*a, &b)
nil
end
end
class String

0 comments on commit d37bf31

Please sign in to comment.