Class: Get::Parser
- Inherits:
-
Object
- Object
- Get::Parser
- Defined in:
- lib/get/parser.rb
Constant Summary collapse
- CLASS_REGEX =
/^(.*)(By|From|JoinedWith)(.*)/
- CLASS_NAME_BY_ERROR =
'You have multiple instances of "By" in your class. Please use open-ended form ie. Get::UserBy.run(params)'
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#method ⇒ Object
Returns the value of attribute method.
-
#result_entity ⇒ Object
Returns the value of attribute result_entity.
Instance Method Summary collapse
-
#initialize(class_name) ⇒ Parser
constructor
A new instance of Parser.
- #key ⇒ Object
- #match? ⇒ Boolean
Constructor Details
#initialize(class_name) ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 11 12 13 |
# File 'lib/get/parser.rb', line 7 def initialize(class_name) raise Get::Errors::InvalidClassName.new(CLASS_NAME_BY_ERROR) if class_name.to_s.split('By').length > 2 @class_name = class_name @match = class_name.to_s.match(CLASS_REGEX) @result_entity, @method, @key_string = @match.values_at(1, 2, 3) if @match end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
5 6 7 |
# File 'lib/get/parser.rb', line 5 def class_name @class_name end |
#method ⇒ Object
Returns the value of attribute method.
5 6 7 |
# File 'lib/get/parser.rb', line 5 def method @method end |
#result_entity ⇒ Object
Returns the value of attribute result_entity.
5 6 7 |
# File 'lib/get/parser.rb', line 5 def result_entity @result_entity end |
Instance Method Details
#key ⇒ Object
19 20 21 |
# File 'lib/get/parser.rb', line 19 def key @key_string.present? ? @key_string.symbolize : nil end |
#match? ⇒ Boolean
15 16 17 |
# File 'lib/get/parser.rb', line 15 def match? !!@match end |