• E
    Begin refactoring ThroughReflection · f8d2899d
    eileencodes 提交于
    This allows us to decouple AssociationReflection and
    ThroughReflection making ThroughReflection it's own Reflection
    bucket in a way. The benefit of this is to be able to remove
    checks against the macro's symbol for exmaple `macro == :belongs_to`.
    
    Get all tests passing again
    
    Some of the methods that used to be inherited from MacroReflection
    through AssociationReflection were no longer getting passed through.
    They needed to be duplicated into the ThroughReflection. I will
    extract these out into a separate class.
    
    Refactor shared methods into strategy object
    
    Now that we've separated ThroughReflection and AssociationReflection
    we can combine shared methods into one class to avoid duplication.
    
    Break out class for each type of reflection
    
    This creates a class for each reflection type (has_many, has_one,
    belongs_to and habtm). We then can remove the need to set the macro
    symbol in each initialization.
    
    Tests were updated to reflect these changes because creation of
    these reflections is now different.
    
    Remove need for @collection instance var
    
    We now define `collection?` as `false` by default and set it to
    `true` in `has_and_belongs_to_many` and `has_many` reflections.
    This removes the need for the `@collection` instance variable.
    
    Raise exception on unknown macro types
    
    We shouldn't accept just any macro when creating reflections. An
    unrecongnized AssociationReflection raises an error. Tests in
    `reflection_test` were updated to reflect these new changes.
    `:has_and_belongs_to_many` macro tests were removed because we no
    longer internally return HABTM.
    f8d2899d
associations.rb 85.4 KB