Class: ActionLabels::ActiveModelNameExtractor
- Inherits:
-
Object
- Object
- ActionLabels::ActiveModelNameExtractor
- Defined in:
- lib/action_labels/active_model_name_extractor.rb
Instance Attribute Summary collapse
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(subject) ⇒ ActiveModelNameExtractor
constructor
A new instance of ActiveModelNameExtractor.
Constructor Details
#initialize(subject) ⇒ ActiveModelNameExtractor
Returns a new instance of ActiveModelNameExtractor.
6 7 8 9 10 11 12 13 14 |
# File 'lib/action_labels/active_model_name_extractor.rb', line 6 def initialize(subject) subject = Array(subject).first if subject.nil? raise ArgumentError, "Cannot extract any meaningful name from NilClass" end @subject = subject end |
Instance Attribute Details
#subject ⇒ Object
Returns the value of attribute subject.
4 5 6 |
# File 'lib/action_labels/active_model_name_extractor.rb', line 4 def subject @subject end |
Instance Method Details
#extract ⇒ Object
16 17 18 19 |
# File 'lib/action_labels/active_model_name_extractor.rb', line 16 def extract klass = subject.is_a?(Class) ? subject : extract_class klass.model_name end |