Class: Subly::Model
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Subly::Model
- Defined in:
- lib/subly/model.rb
Class Method Summary collapse
Class Method Details
.active ⇒ Object
11 12 13 14 |
# File 'lib/subly/model.rb', line 11 def self.active now = Time.zone.now scoped(:conditions => ['starts_at <= ? AND (ends_at > ? OR ends_at IS NULL)', now, now]) end |
.by_name(name) ⇒ Object
26 27 28 |
# File 'lib/subly/model.rb', line 26 def self.by_name(name) scoped(:conditions => {:name => name}) end |
.expired ⇒ Object
16 17 18 19 |
# File 'lib/subly/model.rb', line 16 def self.expired now = Time.zone.now scoped(:conditions => ['starts_at <= ? AND ends_at <= ?', now, now]) end |
.for_subscriber(sub) ⇒ Object
21 22 23 24 |
# File 'lib/subly/model.rb', line 21 def self.for_subscriber(sub) raise ArgumentError('wrong number of arguments (0 for 1)') if sub.blank? scoped(:conditions => ['subscriber_type = ? AND subscriber_id = ?',sub.class.to_s, sub.id]) end |