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. Subclasses must implement #macro method.
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.
- #macro ⇒ Object
- #model_name ⇒ Object
Constructor Details
#initialize(synchronizer, name) ⇒ Association
Returns a new instance of Association.
25 26 27 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 25 def initialize(synchronizer, name) @synchronizer, @name = synchronizer, name.to_sym end |
Class Attribute Details
.valid_options ⇒ Object
Returns the value of attribute valid_options.
14 15 16 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 14 def end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
23 24 25 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 23 def key @key end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
23 24 25 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 23 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 23 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
23 24 25 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 23 def required @required end |
Class Method Details
.create(synchronizer, name, options) ⇒ Object
16 17 18 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 16 def create(synchronizer, name, ) new(synchronizer, name).create() end |
Instance Method Details
#create(options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 29 def create() () @key = [:key] @required = [:required] if [:class_name].present? @model = [:class_name].constantize end set_defaults @synchronizer.associations[@key] = self end |
#macro ⇒ Object
44 45 46 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 44 def macro raise NotImplementedError end |
#model_name ⇒ Object
48 49 50 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 48 def model_name @model.to_s.demodulize.underscore.to_sym end |