Class: Synchronisable::DSL::Associations::Association
- Inherits:
-
Object
- Object
- Synchronisable::DSL::Associations::Association
- Includes:
- Macro
- Defined in:
- lib/synchronisable/dsl/associations/association.rb
Overview
Association builder.
Class Attribute Summary collapse
-
.valid_options ⇒ Object
Returns the value of attribute valid_options.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
Class Method Summary collapse
Instance Method Summary collapse
- #create(options) ⇒ Object
-
#initialize(synchronizer, name) ⇒ Association
constructor
A new instance of Association.
Constructor Details
#initialize(synchronizer, name) ⇒ Association
Returns a new instance of Association.
24 25 26 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 24 def initialize(synchronizer, name) @synchronizer, @name = synchronizer, name.to_sym end |
Class Attribute Details
.valid_options ⇒ Object
Returns the value of attribute valid_options.
13 14 15 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 13 def @valid_options end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
22 23 24 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 22 def key @key end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
22 23 24 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 22 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 22 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
22 23 24 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 22 def required @required end |
Class Method Details
.create(synchronizer, name, options) ⇒ Object
15 16 17 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 15 def create(synchronizer, name, ) new(synchronizer, name).create() end |
Instance Method Details
#create(options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 28 def create() () @key = [:key] @required = [:required] if [:class_name].present? @model = [:class_name].constantize end set_defaults @synchronizer.associations[@key] = self end |