Class: Lagoon::Options
- Inherits:
-
Object
- Object
- Lagoon::Options
- Includes:
- Enumerable, Enumerable[[Symbol,
- Defined in:
- lib/lagoon/options.rb,
sig/lagoon.rbs
Constant Summary collapse
- COMMON_KEYS =
%i[output verbose strict eager_load].freeze
- KEYS =
{ model: COMMON_KEYS + %i[ direction brief show_attributes show_methods include_inheritance exclude specify all_models show_belongs_to hide_through all_columns hide_magic hide_types include_framework_bases duplicate_sti_attributes ], controller: COMMON_KEYS + %i[ direction brief include_inheritance exclude specify all_controllers hide_public hide_protected hide_private include_framework_bases ], er: COMMON_KEYS + %i[exclude specify connections internal_tables], controller_model: COMMON_KEYS + %i[ direction exclude specify all_controllers show_actions helper_models ] }.transform_values(&:freeze).freeze
Instance Attribute Summary collapse
-
#kind ⇒ Symbol
readonly
Returns the value of attribute kind.
Class Method Summary collapse
- .allowed_keys(kind) ⇒ Array[Symbol]
- .for(kind, raw_options = nil, config: Lagoon.configuration, **keyword_options) ⇒ Options
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each {|arg0| ... } ⇒ Options
- #fetch(key, *defaults) {|arg0| ... } ⇒ Object
-
#initialize(kind, raw_options = {}, config: Lagoon.configuration) ⇒ Options
constructor
A new instance of Options.
- #key?(key) ⇒ Boolean
- #to_h ⇒ Hash[Symbol, untyped]
Constructor Details
#initialize(kind, raw_options = {}, config: Lagoon.configuration) ⇒ Options
Returns a new instance of Options.
35 36 37 38 39 40 41 42 |
# File 'lib/lagoon/options.rb', line 35 def initialize(kind, = {}, config: Lagoon.configuration) @kind = kind.to_sym @config = config @raw = symbolize_keys() validate_keys! @values = normalize.freeze freeze end |
Instance Attribute Details
#kind ⇒ Symbol (readonly)
Returns the value of attribute kind.
24 25 26 |
# File 'lib/lagoon/options.rb', line 24 def kind @kind end |
Class Method Details
.allowed_keys(kind) ⇒ Array[Symbol]
31 32 33 |
# File 'lib/lagoon/options.rb', line 31 def self.allowed_keys(kind) KEYS.fetch(kind) end |
.for(kind, raw_options = nil, config: Lagoon.configuration, **keyword_options) ⇒ Options
26 27 28 29 |
# File 'lib/lagoon/options.rb', line 26 def self.for(kind, = nil, config: Lagoon.configuration, **) = ( || {}).to_h.merge() new(kind, , config: config) end |
Instance Method Details
#[](key) ⇒ Object
44 45 46 |
# File 'lib/lagoon/options.rb', line 44 def [](key) @values[key.to_sym] end |
#each {|arg0| ... } ⇒ Options
56 57 58 |
# File 'lib/lagoon/options.rb', line 56 def each(&) @values.each(&) end |
#fetch(key, defaults) ⇒ Object #fetch(key, defaults) ⇒ Object
48 49 50 |
# File 'lib/lagoon/options.rb', line 48 def fetch(key, *defaults, &) @values.fetch(key.to_sym, *defaults, &) end |
#key?(key) ⇒ Boolean
52 53 54 |
# File 'lib/lagoon/options.rb', line 52 def key?(key) @values.key?(key.to_sym) end |
#to_h ⇒ Hash[Symbol, untyped]
60 61 62 |
# File 'lib/lagoon/options.rb', line 60 def to_h @values.dup end |