Sha256: 2b9d13b80a54636d8a42ee105af8b6bbd1b8696ac743ed5839ce5e4b81a4f38b
Contents?: true
Size: 672 Bytes
Versions: 7
Compression:
Stored size: 672 Bytes
Contents
# frozen_string_literal: true module Gifted module Gift attr_accessor :default_decorator def gift(view = nil) @decorator_views ||= { default: gift_delegator } if view @decorator_views[view] ||= gift_delegator(view) else @decorator_views[:default] end end private def gift_delegator(view = nil) decorator = default_decorator if view decorator = default_decorator.const_get("#{view.to_s.camelcase}Decorator") decorator.send :include, Gifted::ViewHelpers unless decorator.is_a?(Class) end SimpleDelegator.new(self).extend decorator end end end
Version data entries
7 entries across 7 versions & 1 rubygems