Class: CubitComponents::StyleDSL
- Inherits:
-
Object
- Object
- CubitComponents::StyleDSL
- Defined in:
- lib/cubit_components/style_dsl.rb
Instance Method Summary collapse
- #config ⇒ Object
- #default(token, replaced_by: nil) ⇒ Object
- #expand(**pairs) ⇒ Object
-
#initialize ⇒ StyleDSL
constructor
A new instance of StyleDSL.
- #presence(token) ⇒ Object
Constructor Details
#initialize ⇒ StyleDSL
Returns a new instance of StyleDSL.
19 20 21 22 23 24 |
# File 'lib/cubit_components/style_dsl.rb', line 19 def initialize @defaults = [] @expansions = {} @pattern_expansions = {} @presences = [] end |
Instance Method Details
#config ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/cubit_components/style_dsl.rb', line 44 def config StyleConfig.new( defaults: @defaults, expansions: @expansions, pattern_expansions: @pattern_expansions, presences: @presences ) end |
#default(token, replaced_by: nil) ⇒ Object
26 27 28 |
# File 'lib/cubit_components/style_dsl.rb', line 26 def default(token, replaced_by: nil) @defaults << StyleConfig::Default.new(token: token, replaced_by: replaced_by.freeze) end |
#expand(**pairs) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/cubit_components/style_dsl.rb', line 30 def (**pairs) pairs.each do |key, value| if key.is_a?(Regexp) @pattern_expansions[key] = value.freeze else @expansions[key] = value.freeze end end end |
#presence(token) ⇒ Object
40 41 42 |
# File 'lib/cubit_components/style_dsl.rb', line 40 def presence(token) @presences << token end |