Class: ActiveData::Model::Associations::Association
- Inherits:
-
Object
- Object
- ActiveData::Model::Associations::Association
- Defined in:
- lib/active_data/model/associations/association.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #class_name ⇒ Object
- #define_accessor(klass) ⇒ Object
- #define_reader(klass) ⇒ Object
- #define_writer(klass) ⇒ Object
-
#initialize(name, options = {}) ⇒ Association
constructor
A new instance of Association.
Constructor Details
#initialize(name, options = {}) ⇒ Association
Returns a new instance of Association.
7 8 9 10 11 |
# File 'lib/active_data/model/associations/association.rb', line 7 def initialize name, = {} @name, @options = name.to_s, @klass ||= [:class] || ([:class_name].to_s.presence || name.to_s.classify).safe_constantize raise "Can not determine class for `#{name}` association" unless @klass end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/active_data/model/associations/association.rb', line 5 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/active_data/model/associations/association.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/active_data/model/associations/association.rb', line 5 def @options end |
Instance Method Details
#class_name ⇒ Object
13 14 15 |
# File 'lib/active_data/model/associations/association.rb', line 13 def class_name klass.to_s end |
#define_accessor(klass) ⇒ Object
17 18 19 20 |
# File 'lib/active_data/model/associations/association.rb', line 17 def define_accessor klass define_reader klass define_writer klass end |
#define_reader(klass) ⇒ Object
22 23 |
# File 'lib/active_data/model/associations/association.rb', line 22 def define_reader klass end |
#define_writer(klass) ⇒ Object
25 26 |
# File 'lib/active_data/model/associations/association.rb', line 25 def define_writer klass end |