Class: Subscription

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ActiveModel::ForbiddenAttributesProtection
Defined in:
app/models/subscription.rb

Constant Summary

WEIGHTS =

Weight Levels

{
  # A very frequent chance of content showing up.
  :very frequently" => 5,
  # A frequent chance of content showing up.
  :frequently => 4,
  # Neither a frequent, nor an infrequent chance of
  # content showing up.
  :no preference" => 3,
  # An infrequent chance of content showing up.
  :rarely => 2,
  # A very infrequent chance of content showing up.
  :very rarely" => 1,
}

Instance Method Summary (collapse)

Instance Method Details

- (Object) contents

Get an array of all the approved active content to be shown in a screen's field.



39
40
41
42
43
44
45
46
# File 'app/models/subscription.rb', line 39

def contents
  @contents = self.feed.approved_contents.active.all
  run_callbacks :filter_contents do
    @contents.reject!{|c| !c.can_display_in?(self.screen, self.field)}
  end

  return @contents
end

- (Object) weight_name

Get weight name of a subscription



34
35
36
# File 'app/models/subscription.rb', line 34

def weight_name
  name = (Subscription::WEIGHTS.respond_to?(:key) ? Subscription::WEIGHTS.key(weight) :  Subscription::WEIGHTS.index(weight)).to_s
end