Module: BrighterPlanet::Emitter
- Defined in:
- lib/emitter.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#included(base) ⇒ Object
“included” not “self.included” why? This module **extends other modules** it forcibly (over)writes their definitions of self.included BrighterPlanet::AutomobileTrip.extend(Emitter) -> now BrighterPlanet::AutomobileTrip has self.included MyAutomobileTrip.include(BrighterPlanet::AutomobileTrip) -> will call BrighterPlanet::AutomobileTrip.included(MyAutomobileTrip).
-
#scope(statement) ⇒ Object
this gets added as a class method to the emitter module.
Instance Method Details
#included(base) ⇒ Object
“included” not “self.included” why? This module **extends other modules** it forcibly (over)writes their definitions of self.included BrighterPlanet::AutomobileTrip.extend(Emitter) -> now BrighterPlanet::AutomobileTrip has self.included MyAutomobileTrip.include(BrighterPlanet::AutomobileTrip) -> will call BrighterPlanet::AutomobileTrip.included(MyAutomobileTrip)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/emitter.rb', line 19 def included(base) base.extend ClassMethods # here self is the emitter module common_name = self.name.demodulize.underscore common_camel = common_name.camelcase base.instance_variable_set :@impact_scope, @impact_scope if @impact_scope base.extend ::Leap::Subject base.send :include, "::BrighterPlanet::#{common_camel}::ImpactModel".constantize base.send :include, ::Charisma base.send :include, "::BrighterPlanet::#{common_camel}::Characterization".constantize base.class_eval do preexisting = characterization.keys decisions[:impact].committees.reject do |committee| preexisting.include?(committee.name) end.each do |committee| characterize do has committee.name, :options => committee..slice(:measures, :display_with) end end end base.send :include, "::BrighterPlanet::#{common_camel}::Data".constantize base.data_miner_script.prepend_once :process, :auto_upgrade! base.data_miner_script.append_once :process, :run_data_miner_on_parent_associations! base.extend ::SummaryJudgement base.send :include, "::BrighterPlanet::#{common_camel}::Summarization".constantize begin require "#{common_name}/fallback" base.send :include, "::BrighterPlanet::#{common_camel}::Fallback".constantize rescue ::LoadError # not required end base.send :include, "::BrighterPlanet::#{common_camel}::Relationships".constantize end |
#scope(statement) ⇒ Object
this gets added as a class method to the emitter module
63 64 65 |
# File 'lib/emitter.rb', line 63 def scope(statement) @impact_scope = statement end |