module Decorum::Decorations::ClassMethods

class method to declare default decorators

Public Instance Methods

class_method_alias(*args)
Alias for: decorum
decorum(*args) click to toggle source
# File lib/decorum/decorations.rb, line 5
def decorum(*args)
  # set first-listed priority
  if args[0] == :reverse
    return @_decorum_stack_reverse = true
  end

  @_decorum_stack ||= []

 if !args.empty? 
    args.each do |arg|
      if (arg.is_a?(Class) && arg.ancestors.include?(Decorum::Decorator)) || arg.is_a?(Hash)
        next if arg.is_a?(Hash)
        klass     = arg
        next_arg  = args[args.index(arg) + 1]
        options   = next_arg.is_a?(Hash) ? next_arg : {}
        @_decorum_stack << [klass, options]
      else
        raise ArgumentError, "invalid argument to #{self.to_s}.decorate_with: #{arg.to_s}"
      end
    end
  else
    @_decorum_stack_reverse ? @_decorum_stack.reverse : @_decorum_stack
  end
end
Also aliased as: class_method_alias