Sha256: f6784fad8b057d4f8ea421927d309534cf898ef5f1c85cc43561806f2f65f2f0
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module InstaSwag class Settings attr_reader :opts, :klass def initialize(klass, opts = {}) @klass = klass @opts = opts.merge defaults end def defaults { api: klass, api_version: klass.version, hide_documentation_path: true, documentation_prefix: DOCUMENTATION_PATH, } end def index_path correct_path Pathname.new(opts[:prefix].to_s + INDEX_PATH).cleanpath.to_path end def assets_path correct_path Pathname.new(opts[:prefix].to_s + ASSETS_PATH).cleanpath.to_path end def prefix_path correct_path opts[:prefix].to_s end private def correct_path path if (path.start_with? "/") && (path.end_with? "/") path[0..-2] elsif path.start_with?("/") && !(path.end_with?("/")) path elsif path.end_with? ("/") "/#{path[0..-2]}" else "/#{path}" end end def method_missing(method, *args, &block) if opts.respond_to? method opts.send(method, *args, &block) else super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
insta_swag-0.1.1 | lib/insta_swag/settings.rb |