Skip to content

Commit c254c7d

Browse files
author
Rafał Trojanowski
committed
variable name more meaningful
1 parent a33618e commit c254c7d

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ is_primary :on=>'is_default', :scope=>'site_id'
5353
# Scope can be defined as array of params
5454
:scope => ['site_id', 'language_code']
5555
:scope => ['polymorphic_id', 'polymorphic_type']
56-
:mark_first => false # Do not mark first record as default
56+
:auto_primary_record => false # if you don't want primary record
57+
# to be set automatically (default: true)
5758
```
5859

5960
##Requirements

lib/primary.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module Primary
22
def is_primary options={}
33
cattr_accessor :primary_is_primary_opts
44
self.primary_is_primary_opts = options.reverse_merge({
5-
:on => :is_primary,
6-
:scope => nil,
7-
:mark_first => true
5+
:on => :is_primary,
6+
:scope => nil,
7+
:auto_primary_record => true
88
})
99

1010
before_save :primary_is_primary_mark
@@ -15,7 +15,7 @@ module InstanceMethods
1515
private
1616
def primary_is_primary_mark
1717
options = self.class.primary_is_primary_opts
18-
return unless !!options[:mark_first]
18+
return unless !!options[:auto_primary_record]
1919

2020
check = get_primary_scope(options)
2121
if check.count == 0

spec/dummy/app/models/background.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Background < ActiveRecord::Base
2-
is_primary mark_first: false
2+
is_primary auto_primary_record: false
33

44
attr_accessible :is_primary, :url
55
end

spec/models/background_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe Background do
44

5-
context 'mark_first is false' do
5+
context 'auto_primary_record is false' do
66
it "should not be marked as default if it's first record" do
77
background = FactoryGirl.build(:background)
88
background.save

0 commit comments

Comments
 (0)