Sha256: b4f169f35e9b46a914114cfd0ea119c22e35caae5b26d73f7237eea3f18e8138
Contents?: true
Size: 1.87 KB
Versions: 4
Compression:
Stored size: 1.87 KB
Contents
require 'active_support/concern' module Upmin::Railties module ActiveRecord extend ::ActiveSupport::Concern included do end module ClassMethods # Add a single attribute to upmin attributes. If this is called # before upmin_attributes the attributes will not include any defaults # attributes. def upmin_attribute(attribute) upmin_attributes unless defined?(@upmin_attributes) attribute = attribute.to_sym @upmin_attributes << attribute unless @upmin_attributes.include?(attribute) end # Sets the upmin_attributes to the provided attributes if any are # provided. # If no attributes are provided, and upmin_attributes hasn't been defined, # then the upmin_attributes are set to the default attributes. # Returns the upmin_attributes def upmin_attributes(*attributes) if attributes.any? @upmin_attributes = attributes.map{|a| a.to_sym} end @upmin_attributes ||= attribute_names.map{|a| a.to_sym} return @upmin_attributes end # Add a single action to upmin actions. If this is called # before upmin_actions the actions will not include any defaults # actions. def upmin_action(action) @upmin_actions ||= [] action = action.to_sym @upmin_actions << action unless @upmin_actions.include?(attribute) end # Sets the upmin_actions to the provided actions if any are # provided. # If no actions are provided, and upmin_actions hasn't been defined, # then the upmin_actions are set to the default actions. # Returns the upmin_actions def upmin_actions(*actions) if actions.any? # set the actions @upmin_actions = actions.map{|a| a.to_sym} end @upmin_actions ||= [] return @upmin_actions end end end end
Version data entries
4 entries across 4 versions & 1 rubygems