Class: TsSchema::Configuration
- Inherits:
-
Object
- Object
- TsSchema::Configuration
- Defined in:
- lib/ts_schema/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ case: :camel, output: -> { Rails.root.join('app', 'assets', 'javascripts', 'schema.d.ts') }, auto_generate: true, types: ->{ YAML.load_file("#{File.(__dir__)}/conversion_table.yml").to_h }, custom_types: {}, export_nulls: false, 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, }.freeze
Instance Method Summary collapse
- #assign(attributes = nil, &block) ⇒ Object
-
#initialize(attributes = nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(attributes = nil) ⇒ Configuration
Returns a new instance of Configuration.
31 32 33 34 35 36 |
# File 'lib/ts_schema/configuration.rb', line 31 def initialize(attributes = nil) assign(DEFAULTS) return unless attributes assign(attributes) end |
Instance Method Details
#assign(attributes = nil, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ts_schema/configuration.rb', line 38 def assign(attributes = nil, &block) if !attributes && !block raise "Provide attributes or block" end tap(&block) if block attributes&.each do |attribute, value| value = value.call if value.is_a?(Proc) send(:"#{attribute}=", value) end self end |