Module: Warped::Emails::Styleable

Included in:
Base
Defined in:
lib/warped/emails/styleable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
# File 'lib/warped/emails/styleable.rb', line 11

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#base_stylesObject



58
59
60
# File 'lib/warped/emails/styleable.rb', line 58

def base_styles
  self.class.base_styles
end

#default_variantsObject



54
55
56
# File 'lib/warped/emails/styleable.rb', line 54

def default_variants
  self.class.default_variants
end

#style(variant_name = :_base_variant, **kwargs) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/warped/emails/styleable.rb', line 66

def style(variant_name = :_base_variant, **kwargs)
  base_style_arr = base_block_value(variant_name)

  validate_variants!(variant_name, **kwargs)

  default_variants[variant_name] ||= {}
  default_variants[variant_name].merge(kwargs.compact_blank).each do |group_name, subvariant_name|
    subvariant_arr = variant_block_value(variant_name, group_name, subvariant_name)
    base_style_arr.concat(subvariant_arr)
  end

  base_style_arr.join("; ")
end

#variantsObject



62
63
64
# File 'lib/warped/emails/styleable.rb', line 62

def variants
  self.class.variants
end