Sha256: 6b58ac291a3d96ec67e8ee731be352825c40d904c6be10247252a553e9bb44fd
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
module Praxis class ApiGeneralInfo def initialize(global_info=nil) @global_info = global_info @data = Hash.new end def get(k) return @data[k] if @data.key?(k) return @global_info.get(k) if @global_info nil end def set(k, v) @data[k] = v end def name(val=nil) if val.nil? get(:name) else set(:name, val) end end def title(val=nil) if val.nil? get(:title) else set(:title, val) end end def description(val=nil) if val.nil? get(:description) else set(:description, val) end end 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 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
praxis-0.16.1 | lib/praxis/api_general_info.rb |
praxis-0.16.0 | lib/praxis/api_general_info.rb |