Class: EnumerizeSchema::Configuration
- Inherits:
-
Object
- Object
- EnumerizeSchema::Configuration
- Defined in:
- lib/enumerize_schema/configuration.rb
Instance Attribute Summary collapse
-
#default_config ⇒ Hash
readonly
The default config.
Instance Method Summary collapse
-
#schema_file ⇒ Pathname
The path to the schema file containing all the enum values.
-
#schema_file=(value) ⇒ Pathname
The path to the schema file containing all the enum values.
Instance Attribute Details
#default_config ⇒ Hash (readonly)
Returns the default config.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/enumerize_schema/configuration.rb', line 10 def default_config return @default_config if @default_config config = {} if defined?(Rails) config[:schema_file] = Rails.root.join("config", "enumerize.yml") else root_path = Pathname.new(defined?(Bundler) ? Bundler.root : Dir.pwd) config[:schema_file] = root_path.join("enumerize.yml") end @default_config = config.freeze end |
Instance Method Details
#schema_file ⇒ Pathname
Returns the path to the schema file containing all the enum values.
27 28 29 |
# File 'lib/enumerize_schema/configuration.rb', line 27 def schema_file @schema_file ||= default_config[:schema_file] end |
#schema_file=(value) ⇒ Pathname
Returns the path to the schema file containing all the enum values.
35 36 37 38 39 40 41 42 43 |
# File 'lib/enumerize_schema/configuration.rb', line 35 def schema_file=(value) if !File.file?(value) raise SchemaFileNotFoundError.new(schema_file: value) elsif !File.readable?(value) raise SchemaFileNotReadableError.new(schema_file: value) else @schema_file = Pathname.new(value) end end |