Class: ObjectAttorney::Reflection
- Inherits:
-
Object
- Object
- ObjectAttorney::Reflection
- Defined in:
- lib/object_attorney/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.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/object_attorney/reflection.rb', line 6 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 end end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/object_attorney/reflection.rb', line 4 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/object_attorney/reflection.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/object_attorney/reflection.rb', line 4 def @options end |
Instance Method Details
#plural_name ⇒ Object
24 25 26 |
# File 'lib/object_attorney/reflection.rb', line 24 def plural_name @plural_name ||= [:plural_name] || name.to_s.pluralize end |
#single_name ⇒ Object
20 21 22 |
# File 'lib/object_attorney/reflection.rb', line 20 def single_name @single_name ||= [:single_name] || Helpers.singularize(name) end |