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
-
#force_sync ⇒ Object
readonly
Returns the value of attribute force_sync.
-
#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.
26 27 28 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 26 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 @valid_options end |
Instance Attribute Details
#force_sync ⇒ Object (readonly)
Returns the value of attribute force_sync.
23 24 25 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 23 def force_sync @force_sync end |
#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
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 30 def create() () @key = [:key] @required = [:required] @force_sync = [:force_sync] if [:class_name].present? @model = [:class_name].constantize end set_defaults @synchronizer.associations[@key] = self end |
#macro ⇒ Object
46 47 48 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 46 def macro raise NotImplementedError end |
#model_name ⇒ Object
50 51 52 |
# File 'lib/synchronisable/dsl/associations/association.rb', line 50 def model_name @model.to_s.demodulize.underscore.to_sym end |