Skip to content

Commit

Permalink
Refactor ActAstimeAsBoolean::Concern
Browse files Browse the repository at this point in the history
  • Loading branch information
caedes committed Nov 24, 2014
1 parent ff8956c commit 9e1357e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/act_as_time_as_boolean/concern.rb
Expand Up @@ -25,6 +25,10 @@ def time_as_boolean(field, options = {})
save!
end

scope field, -> {
where "#{table_name}.#{field}_at IS NOT NULL AND #{table_name}.#{field}_at <= ?", Time.current
}

if options[:opposite]
opposite = options[:opposite]
define_method :"#{opposite}" do
Expand All @@ -41,10 +45,6 @@ def time_as_boolean(field, options = {})
where "#{table_name}.#{field}_at IS NULL OR #{table_name}.#{field}_at > ?", Time.current
}
end

scope field, -> {
where "#{table_name}.#{field}_at IS NOT NULL AND #{table_name}.#{field}_at <= ?", Time.current
}
end
end
end

0 comments on commit 9e1357e

Please sign in to comment.