Class: RemoteResource::AssociationBuilder
- Inherits:
-
Object
- Object
- RemoteResource::AssociationBuilder
- Defined in:
- lib/remote_resource/association_builder.rb
Overview
The AssociationBuilder class is responsible for defining a method(s) on a target object that refers to an associated Base class. The body of that method instantiates an attributes class.
Instance Attribute Summary collapse
-
#base_class ⇒ Object
readonly
Returns the value of attribute base_class.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #associated_with(target_class) ⇒ Object
-
#initialize(base_class, options = {}) ⇒ AssociationBuilder
constructor
A new instance of AssociationBuilder.
Constructor Details
#initialize(base_class, options = {}) ⇒ AssociationBuilder
Returns a new instance of AssociationBuilder.
8 9 10 11 |
# File 'lib/remote_resource/association_builder.rb', line 8 def initialize(base_class, = {}) @base_class = base_class = () end |
Instance Attribute Details
#base_class ⇒ Object (readonly)
Returns the value of attribute base_class.
6 7 8 |
# File 'lib/remote_resource/association_builder.rb', line 6 def base_class @base_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/remote_resource/association_builder.rb', line 6 def end |
Instance Method Details
#associated_with(target_class) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/remote_resource/association_builder.rb', line 13 def associated_with(target_class) method_name = [:as] set_associated_class(method_name, target_class) define_association_method(method_name, target_class) self end |