Sha256: e2caf3312cf763575641656c292337eb9b9cb8265fcae3a11c69893385e28d62
Contents?: true
Size: 976 Bytes
Versions: 2
Compression:
Stored size: 976 Bytes
Contents
require 'active_support/inflector' module Brightcontent module ViewLookup class Abstract attr_reader :options, :view_context def initialize(view_context, options) @view_context = view_context @options = options end def call render_by_field_name || render_by_type || render_default end private def render_by_field_name render("#{name}_#{options[:field]}", options) end def render_by_type return unless field_type render("brightcontent/base/#{name.pluralize}/#{field_type}", options) end def render_default field_value end def field_type raise NotImplementedError end def name self.class.name.demodulize.underscore end def field_value options[:item].send(options[:field]) end def render(*args) view_context.render_if_exists(*args) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
brightcontent-core-2.1.1 | lib/brightcontent/view_lookup/abstract.rb |
brightcontent-core-2.1.0 | lib/brightcontent/view_lookup/abstract.rb |