Sha256: 768909522f33239f0f32d4f476a6b06f4356083a79302d3106c70d9263091911
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require 'satchel/activity_data_structure' require 'satchel/exceptions' module Satchel class ActivityBuilder attr_accessor :configuration_proc, :activity_receiver private :activity_receiver=, :configuration_proc= def initialize(activity_receiver, configuration_proc) unless activity_receiver.respond_to?(:call) raise RuntimeError, "Excpected :activity_receiver #{activity_receiver.inspect} to be callable" end unless configuration_proc.respond_to?(:call) raise RuntimeError, "Excpected :configuration_proc #{configuration_proc.inspect} to be callable" end self.activity_receiver = activity_receiver self.configuration_proc = configuration_proc end def call(context) configuration_proc.call(self, context) activity_receiver.call(self.to_activity_data_structure) end def to_activity_data_structure ActivityDataStructure.new.tap {|ads| ads.subject = subject ads.current_user = current_user ads.message = message ads.activity_type = activity_type } end def subject=(persisted_object) if persisted_object.persisted? @subject = persisted_object else raise UnpersistedSubjectError.new(persisted_object) end end attr_reader :subject attr_accessor :current_user, :message, :activity_type end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
satchel-0.0.2 | lib/satchel/activity_builder.rb |
satchel-0.0.1 | lib/satchel/activity_builder.rb |