Class: DelegateCached::CachedAttribute
- Inherits:
-
Object
- Object
- DelegateCached::CachedAttribute
- Defined in:
- lib/delegate_cached/cached_attribute.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(model, attribute, reflection, options) ⇒ CachedAttribute
constructor
A new instance of CachedAttribute.
- #install! ⇒ Object
Constructor Details
#initialize(model, attribute, reflection, options) ⇒ CachedAttribute
Returns a new instance of CachedAttribute.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/delegate_cached/cached_attribute.rb', line 10 def initialize(model, attribute, reflection, ) @options = @source = source_model_data(model, attribute, reflection, ) inverse = nil if reflection.polymorphic? @options[:polymorphic] = true else inverse = reflection.inverse_of inverse ||= retrieve_reflection([:inverse_of]) @options[:skip_callback] = true if inverse.nil? end @target = target_model_data(attribute, reflection, inverse) @source_installer = SourceInstaller.new(@source, @target, ) @target_installer = TargetInstaller.new(@source, @target, ) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/delegate_cached/cached_attribute.rb', line 8 def @options end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/delegate_cached/cached_attribute.rb', line 8 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
8 9 10 |
# File 'lib/delegate_cached/cached_attribute.rb', line 8 def target @target end |
Instance Method Details
#install! ⇒ Object
29 30 31 32 33 |
# File 'lib/delegate_cached/cached_attribute.rb', line 29 def install! validate @source_installer.install_instance_methods @target_installer.install_instance_methods end |