Module: MyFeeds::Feeder::ClassMethods

Defined in:
lib/my_feeds/feeder.rb

Instance Method Summary collapse

Instance Method Details

#define_feed_event(event, conditions = {}) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/my_feeds/feeder.rb', line 10

def define_feed_event event, conditions = {}
  conditions.freeze
  define_method(event) do |options = {}|
    attributes = {source_type: self.class.to_s, source_id: self.id, event: event}.merge!(conditions).merge! options
    Feed.create attributes
  end

  define_method("#{event}_feeds") do
    source_feeds.where({event: event}.merge! conditions)
  end
end