Module: Promiscuous::Publisher::Model::Mock::ClassMethods
- Defined in:
- lib/promiscuous/publisher/model/mock.rb
Instance Method Summary collapse
Instance Method Details
#mock(options = {}) ⇒ Object
42 43 44 45 |
# File 'lib/promiscuous/publisher/model/mock.rb', line 42 def mock(={}) # careful, all subclasses will be touched self..merge!() end |
#publish(*args, &block) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/promiscuous/publisher/model/mock.rb', line 47 def publish(*args, &block) super args. attributes = args attr_accessor(*attributes) # Hacks for associations on the factory associations = attributes.map { |attr| $1 if attr =~ /^(.*)_id$/ }.compact associations.each do |attr| attr_accessor(attr) define_method("#{attr}=") do |value| instance_variable_set("@#{attr}", value) instance_variable_set("@#{attr}_id", value.nil? ? value : value.id) end end end |
#publish_as ⇒ Object
37 38 39 40 |
# File 'lib/promiscuous/publisher/model/mock.rb', line 37 def publish_as # The mocks are in the publisher's namespace, so we need to remove that. @publish_as ||= ($2 if self.name =~ /^(.+)::Publishers::(.+)$/) end |