Sha256: a793f1fe564aae467fe1ac96f7e159118ec1ee3a57405c413bed3522aaade328
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
require "pathname" module TsSchema class Configuration DEFAULTS = { case: :camel, output: -> { Rails.root.join('app', 'assets', 'javascripts', 'schema.d.ts') }, auto_generate: true, types: ->{ YAML.load_file(File.expand_path(__dir__) + '/conversion_table.yml').to_h }, custom_types: {}, default_type: :string, include_associated: true, parent_classes: ["ApplicationRecord"], additional_models: [], field_overrides: { "encrypted_password" => :password, "password" => :optional, }, field_type_overrides: {}, namespace: :schema, schema_type: :interface, indent: :tab, spaces: 2, } attr_accessor(*DEFAULTS.keys) def initialize(attributes = nil) assign(DEFAULTS) return unless attributes assign(attributes) end def assign(attributes = nil, &block) if !attributes && !block raise "Provide attributes or block" end tap(&block) if block if attributes attributes.each do |attribute, value| value = value.call if value.is_a?(Proc) send(:"#{attribute}=", value) end end self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ts_schema-0.2.1 | lib/ts_schema/configuration.rb |