Class: Praxis::ApiGeneralInfo
- Inherits:
-
Object
- Object
- Praxis::ApiGeneralInfo
- Defined in:
- lib/praxis/api_general_info.rb
Instance Method Summary collapse
- #base_params(type = Attributor::Struct, **opts, &block) ⇒ Object
- #base_path(val = nil) ⇒ Object
- #describe ⇒ Object
- #description(val = nil) ⇒ Object
- #get(k) ⇒ Object
-
#initialize(global_info = nil) ⇒ ApiGeneralInfo
constructor
A new instance of ApiGeneralInfo.
- #name(val = nil) ⇒ Object
- #set(k, v) ⇒ Object
- #title(val = nil) ⇒ Object
Constructor Details
#initialize(global_info = nil) ⇒ ApiGeneralInfo
Returns a new instance of ApiGeneralInfo.
4 5 6 7 |
# File 'lib/praxis/api_general_info.rb', line 4 def initialize(global_info=nil) @global_info = global_info @data = Hash.new end |
Instance Method Details
#base_params(type = Attributor::Struct, **opts, &block) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/praxis/api_general_info.rb', line 57 def base_params(type=Attributor::Struct, **opts, &block) if !block && type == Attributor::Struct get(:base_params) else set(:base_params, Attributor::Attribute.new(type, opts, &block) ) end end |
#base_path(val = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/praxis/api_general_info.rb', line 43 def base_path(val=nil) if val return set(:base_path, val) end if @global_info version_path = @data.fetch(:base_path,'') global_path = @global_info.get(:base_path) "#{global_path}#{version_path}" else @data.fetch(:base_path,'') end end |
#describe ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/praxis/api_general_info.rb', line 65 def describe hash = { schema_version: "1.0".freeze } [:name, :title, :description, :base_path].each do |attr| val = self.__send__(attr) hash[attr] = val unless val.nil? end if base_params hash[:base_params] = base_params.describe[:type][:attributes] end hash end |
#description(val = nil) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/praxis/api_general_info.rb', line 35 def description(val=nil) if val.nil? get(:description) else set(:description, val) end end |
#get(k) ⇒ Object
9 10 11 12 13 |
# File 'lib/praxis/api_general_info.rb', line 9 def get(k) return @data[k] if @data.key?(k) return @global_info.get(k) if @global_info nil end |
#name(val = nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/praxis/api_general_info.rb', line 19 def name(val=nil) if val.nil? get(:name) else set(:name, val) end end |
#set(k, v) ⇒ Object
15 16 17 |
# File 'lib/praxis/api_general_info.rb', line 15 def set(k, v) @data[k] = v end |
#title(val = nil) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/praxis/api_general_info.rb', line 27 def title(val=nil) if val.nil? get(:title) else set(:title, val) end end |