Sha256: c632f9bf412582bbadaa2aac8a0954ff7ce064f1f660fb01874e78d7530eb1f9

Contents?: true

Size: 814 Bytes

Versions: 15

Compression:

Stored size: 814 Bytes

Contents

module ActiveRecord
  
  class Base
    
    def self.reflect_on_all_aggregations
      base_class.instance_eval { @aggregations ||= [] }
    end
    
    def self.reflect_on_aggregation(attribute)
      reflect_on_all_aggregations.detect { |aggregation| aggregation.attribute == attribute }
    end
    
  end
  
  module Aggregations
    
    class AggregationReflection
      
      attr_reader :klass_name
      attr_reader :attribute
      
      def initialize(owner_class, macro, name, options = {})
        owner_class.reflect_on_all_aggregations << self
        @owner_class = owner_class
        @klass_name =  options[:class_name] || name.camelize
        @attribute =   name
      end
      
      def klass
        @klass ||= Object.const_get(@klass_name)
      end
      
    end
    
  end
  
  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
reactive-record-0.7.16 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.15 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.14 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.13 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.12 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.11 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.10 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.9 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.8 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.7 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.6 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.5 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.4 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.1 lib/reactive_record/active_record/aggregations.rb
reactive-record-0.7.0 lib/reactive_record/active_record/aggregations.rb