Class: Emjay::GlobalData
- Inherits:
-
Object
- Object
- Emjay::GlobalData
- Defined in:
- lib/emjay/global_data.rb
Constant Summary collapse
- ARRAY_FIELDS =
%i[inline_style components_head_style head_raw style].freeze
- HASH_FIELDS =
%i[classes classes_default default_attributes html_attributes fonts head_style media_queries].freeze
- SCALAR_FIELDS =
%i[before_doctype breakpoint preview title force_owa_desktop lang dir].freeze
Instance Method Summary collapse
-
#add(key, *params) ⇒ Object
Mirrors JS headHelpers.add() semantics.
-
#initialize(options = {}) ⇒ GlobalData
constructor
A new instance of GlobalData.
Constructor Details
#initialize(options = {}) ⇒ GlobalData
Returns a new instance of GlobalData.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/emjay/global_data.rb', line 11 def initialize( = {}) @before_doctype = "" @breakpoint = [:breakpoint] || "480px" @classes = {} @classes_default = {} @default_attributes = {} @html_attributes = {} @fonts = .fetch(:fonts, default_fonts) @inline_style = [] @head_style = {} @components_head_style = [] @head_raw = [] @media_queries = {} @preview = "" @style = [] @title = "" @force_owa_desktop = false @lang = "und" @dir = "auto" end |
Instance Method Details
#add(key, *params) ⇒ Object
Mirrors JS headHelpers.add() semantics
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/emjay/global_data.rb', line 33 def add(key, *params) val = send(key) if val.is_a?(Array) val.push(*params) elsif val.is_a?(Hash) if params.length > 1 val[params[0]] = if val[params[0]].is_a?(Hash) val[params[0]].merge(params[1]) else params[1] end else send(:"#{key}=", params[0]) end else send(:"#{key}=", params[0]) end end |