Sha256: ab2b146538b2123adb754bb6cad43eca66d9883c37de241f46c578b0d968417b
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
motion_require '../helpers/has_normalizer' module MotionPrime class Styles @@repo = {} def initialize(namespace = nil) @namespace = namespace end def style(name, options = {}) name = "#{@namespace}_#{name}".to_sym if @namespace @@repo[name] ||= {} if parent = options.delete(:parent) parent ="#{@namespace}_#{parent}".to_sym if @namespace @@repo[name].deep_merge! self.class.for(parent) end @@repo[name].deep_merge! options end class << self include HasNormalizer def define(namespace = nil, &block) self.new(namespace).instance_eval(&block) end def for(style_names) style_options = {} Array.wrap(style_names).each do |name| style_options.deep_merge!(@@repo[name] || {}) end style_options end def extend_and_normalize_options(options = {}) style_options = self.for(options.delete(:styles)) normalize_options(style_options.merge(options)) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems