Class: JsonStatham::Requests::Base
- Inherits:
-
Object
- Object
- JsonStatham::Requests::Base
- Extended by:
- Forwardable
- Defined in:
- lib/json_statham/requests/base.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Class Method Summary collapse
Instance Method Summary collapse
- #base_path ⇒ Object
- #call ⇒ Object
- #file_path ⇒ Object
- #folder? ⇒ Boolean
- #folder_path ⇒ Object
-
#initialize(parser) ⇒ Base
constructor
A new instance of Base.
- #schema_name ⇒ Object
- #splitted_name ⇒ Object
Constructor Details
#initialize(parser) ⇒ Base
Returns a new instance of Base.
20 21 22 23 24 25 |
# File 'lib/json_statham/requests/base.rb', line 20 def initialize(parser) Validation.check_object_class(parser, [JsonStatham::Parser]) @parser = parser @config = JsonStatham.config end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
10 11 12 |
# File 'lib/json_statham/requests/base.rb', line 10 def parser @parser end |
Class Method Details
.call(parser) ⇒ Object
16 17 18 |
# File 'lib/json_statham/requests/base.rb', line 16 def self.call(parser) new(parser).call end |
Instance Method Details
#base_path ⇒ Object
27 28 29 30 31 |
# File 'lib/json_statham/requests/base.rb', line 27 def base_path return "#{schemas_path}/#{folder_path}" if folder? schemas_path end |
#call ⇒ Object
55 56 57 |
# File 'lib/json_statham/requests/base.rb', line 55 def call raise NotImplementedError end |
#file_path ⇒ Object
37 38 39 |
# File 'lib/json_statham/requests/base.rb', line 37 def file_path "#{base_path}/#{schema_name}.json" end |
#folder? ⇒ Boolean
33 34 35 |
# File 'lib/json_statham/requests/base.rb', line 33 def folder? !!folder_path end |
#folder_path ⇒ Object
45 46 47 48 49 |
# File 'lib/json_statham/requests/base.rb', line 45 def folder_path return if splitted_name.length == 1 splitted_name.reverse.drop(1).reverse.join("/") end |
#schema_name ⇒ Object
41 42 43 |
# File 'lib/json_statham/requests/base.rb', line 41 def schema_name splitted_name.last end |
#splitted_name ⇒ Object
51 52 53 |
# File 'lib/json_statham/requests/base.rb', line 51 def splitted_name name.split("/") end |