Class: SmoothOperator::Associations::Reflection
- Inherits:
-
Object
- Object
- SmoothOperator::Associations::Reflection
- Defined in:
- lib/smooth_operator/associations/reflection.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
-
#initialize(class_name, options) ⇒ Reflection
constructor
A new instance of Reflection.
- #plural_name ⇒ Object
- #single_name ⇒ Object
Constructor Details
#initialize(class_name, options) ⇒ Reflection
Returns a new instance of Reflection.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/smooth_operator/associations/reflection.rb', line 7 def initialize(class_name, ) = .is_a?(Hash) ? : {} @name, @options = class_name, @klass = [:class_name] || klass_default(@name) if .include?(:class_name) && [:class_name].nil? @klass = nil elsif @klass.is_a?(String) @klass = @klass.constantize rescue OpenStruct end end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/smooth_operator/associations/reflection.rb', line 5 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/smooth_operator/associations/reflection.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/smooth_operator/associations/reflection.rb', line 5 def @options end |
Instance Method Details
#plural_name ⇒ Object
25 26 27 |
# File 'lib/smooth_operator/associations/reflection.rb', line 25 def plural_name @plural_name ||= [:plural_name] || name.to_s.pluralize end |
#single_name ⇒ Object
21 22 23 |
# File 'lib/smooth_operator/associations/reflection.rb', line 21 def single_name @single_name ||= [:single_name] || name.to_s.singularize end |