Sha256: 90b034bae620ac0bf165517ddd729fed6f73fddb03c7f2141533b4b765657556
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require 'tramway/decorators/collection_decorator' require 'tramway/utils/decorators/render' module Tramway # Provides decorate function for Tramway projects # class BaseDecorator include Tramway::Decorators::CollectionDecorators include Tramway::Utils::Decorators::Render attr_reader :object def initialize(object) @object = object end class << self def decorate(object_or_array) if Tramway::Decorators::CollectionDecorators.collection?(object_or_array) Tramway::Decorators::CollectionDecorators.decorate_collection( collection: object_or_array, decorator: self ) else new(object_or_array) end end def delegate_attributes(*args) args.each do |attribute| delegate attribute, to: :object end end end delegate_attributes :id def to_partial_path underscored_class_name = object.class.name.underscore "#{underscored_class_name.pluralize}/#{underscored_class_name}" end def to_param id.to_s end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tramway-0.2.1.3 | lib/tramway/base_decorator.rb |