motion-prime/views/styles.rb in motion-prime-0.7.0 vs motion-prime/views/styles.rb in motion-prime-0.7.1

- old
+ new

@@ -11,20 +11,20 @@ names = Array.wrap(args) options = names.pop if args.last.is_a?(Hash) if options.present? parent = options.delete(:parent) - if parent_namespace = options.delete(:parent_namespace) || @namespace + if parent && (parent_namespace = options.delete(:parent_namespace) || @namespace) parent ="#{parent_namespace}_#{parent}".to_sym end mixins = Array.wrap(options.delete(:mixins)).map { |mixin_name| :"_mixin_#{mixin_name}" } names.each do |name| name = "#{@namespace}_#{name}".to_sym if @namespace @@repo[name] ||= {} - @@repo[name].deep_merge!(self.class.for(parent)) if parent - @@repo[name].deep_merge!(self.class.for(mixins)) if mixins.present? + @@repo[name].deep_merge!(self.class.for(parent, debug_missing: true, type: :parent, name: name)) if parent + @@repo[name].deep_merge!(self.class.for(mixins, debug_missing: true, type: :mixin, name: name)) if mixins.present? @@repo[name].deep_merge! options end elsif !block_given? raise "No style rules specified for `#{names.join(', ')}`. Namespace: `#{@namespace}`" end @@ -55,13 +55,15 @@ block = definition[:block] self.new(definition[:namespace]).instance_eval(&block) end end - def for(style_names) + def for(style_names, options = {}) style_options = {} Array.wrap(style_names).each do |name| - style_options.deep_merge!(@@repo[name] || {}) + styles = @@repo[name] + Prime.logger.debug "No styles found for `#{name}` (element: `#{options[:name]}`, type: #{options.fetch(:type, 'general')})" if options[:debug_missing] && styles.blank? + style_options.deep_merge!(styles || {}) end style_options end def extend_and_normalize_options(options = {}) \ No newline at end of file