Module: Upmin::Railties::ActiveRecord::ClassMethods

Defined in:
lib/upmin/railties/active_record.rb

Instance Method Summary collapse

Instance Method Details

#upmin_action(action) ⇒ Object

Add a single action to upmin actions. If this is called before upmin_actions the actions will not include any defaults actions.



39
40
41
42
43
44
# File 'lib/upmin/railties/active_record.rb', line 39

def upmin_action(action)
  @upmin_actions ||= []

  action = action.to_sym
  @upmin_actions << action unless @upmin_actions.include?(attribute)
end

#upmin_actions(*actions) ⇒ Object

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



51
52
53
54
55
56
57
58
# File 'lib/upmin/railties/active_record.rb', line 51

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

#upmin_attribute(attribute) ⇒ Object

Add a single attribute to upmin attributes. If this is called before upmin_attributes the attributes will not include any defaults attributes.



15
16
17
18
19
20
# File 'lib/upmin/railties/active_record.rb', line 15

def upmin_attribute(attribute)
  upmin_attributes unless defined?(@upmin_attributes)

  attribute = attribute.to_sym
  @upmin_attributes << attribute unless @upmin_attributes.include?(attribute)
end

#upmin_attributes(*attributes) ⇒ Object

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



27
28
29
30
31
32
33
# File 'lib/upmin/railties/active_record.rb', line 27

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