Class: GroupedScope::AssociationReflection

Inherits:
ActiveRecord::Reflection::AssociationReflection
  • Object
show all
Defined in:
lib/grouped_scope/association_reflection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_record, ungrouped_name) ⇒ AssociationReflection

Returns a new instance of AssociationReflection.



11
12
13
14
15
16
17
18
# File 'lib/grouped_scope/association_reflection.rb', line 11

def initialize(active_record,ungrouped_name)
  @active_record = active_record
  @ungrouped_name = ungrouped_name
  @name = :"grouped_scope_#{@ungrouped_name}"
  verify_ungrouped_reflection
  super(ungrouped_reflection.macro, @name, ungrouped_reflection.options.dup, @active_record)
  create_grouped_association
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



31
32
33
# File 'lib/grouped_scope/association_reflection.rb', line 31

def method_missing(method, *args, &block)
  ungrouped_reflection.send(method, *args, &block)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/grouped_scope/association_reflection.rb', line 9

def name
  @name
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/grouped_scope/association_reflection.rb', line 9

def options
  @options
end

Instance Method Details

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/grouped_scope/association_reflection.rb', line 24

def respond_to?(method, include_private=false)
  super || ungrouped_reflection.respond_to?(method,include_private)
end

#ungrouped_reflectionObject



20
21
22
# File 'lib/grouped_scope/association_reflection.rb', line 20

def ungrouped_reflection
  @active_record.reflections[@ungrouped_name]
end