Class: CubitComponents::StyleDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/cubit_components/style_dsl.rb

Instance Method Summary collapse

Constructor Details

#initializeStyleDSL

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

#configObject



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 expand(**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