Class: Develoz::Options
- Inherits:
-
Object
- Object
- Develoz::Options
- Defined in:
- lib/develoz/options.rb
Constant Summary collapse
- OPT_IN_FLAGS =
Opt-in feature flags (default false)
%i[api auth pwa push active_resource admin ui kamal docker db_backup].freeze
- OPT_OUT_FLAGS =
Opt-out flags (default false → feature is included unless skipped)
%i[skip_pagy].freeze
- VALID_KEYS =
All valid flag keys
(OPT_IN_FLAGS + OPT_OUT_FLAGS + %i[app_name ruby_version rails_version]).freeze
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#rails_version ⇒ Object
readonly
Returns the value of attribute rails_version.
-
#ruby_version ⇒ Object
readonly
Returns the value of attribute ruby_version.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/develoz/options.rb', line 16 def initialize( = {}) unknown_keys = .keys - VALID_KEYS raise ArgumentError, "Unknown option(s): #{unknown_keys.join(', ')}" if unknown_keys.any? @app_name = [:app_name] @ruby_version = [:ruby_version] @rails_version = [:rails_version] # Initialize opt-in flags (default false) OPT_IN_FLAGS.each do |flag| instance_variable_set("@#{flag}", [flag] || false) end # Initialize opt-out flags (default false) OPT_OUT_FLAGS.each do |flag| instance_variable_set("@#{flag}", [flag] || false) end end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
14 15 16 |
# File 'lib/develoz/options.rb', line 14 def app_name @app_name end |
#rails_version ⇒ Object (readonly)
Returns the value of attribute rails_version.
14 15 16 |
# File 'lib/develoz/options.rb', line 14 def rails_version @rails_version end |
#ruby_version ⇒ Object (readonly)
Returns the value of attribute ruby_version.
14 15 16 |
# File 'lib/develoz/options.rb', line 14 def ruby_version @ruby_version end |
Instance Method Details
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/develoz/options.rb', line 45 def to_h { app_name: @app_name, ruby_version: @ruby_version, rails_version: @rails_version, **OPT_IN_FLAGS.index_with { |flag| instance_variable_get("@#{flag}") }, **OPT_OUT_FLAGS.index_with { |flag| instance_variable_get("@#{flag}") } } end |