Class: Pageflow::EntryPublication

Inherits:
Object
  • Object
show all
Defined in:
app/models/pageflow/entry_publication.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry, attributes, published_entries_quota, user) ⇒ EntryPublication


5
6
7
8
9
10
# File 'app/models/pageflow/entry_publication.rb', line 5

def initialize(entry, attributes, published_entries_quota, user)
  @entry = entry
  @attributes = attributes
  @quota = published_entries_quota
  @user = user
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes


3
4
5
# File 'app/models/pageflow/entry_publication.rb', line 3

def attributes
  @attributes
end

#entryObject (readonly)

Returns the value of attribute entry


3
4
5
# File 'app/models/pageflow/entry_publication.rb', line 3

def entry
  @entry
end

#quotaObject (readonly)

Returns the value of attribute quota


3
4
5
# File 'app/models/pageflow/entry_publication.rb', line 3

def quota
  @quota
end

#userObject (readonly)

Returns the value of attribute user


3
4
5
# File 'app/models/pageflow/entry_publication.rb', line 3

def user
  @user
end

Instance Method Details

#exceeding?Boolean


12
13
14
# File 'app/models/pageflow/entry_publication.rb', line 12

def exceeding?
  assumed_quota.exceeded?
end

#save!Object


16
17
18
19
# File 'app/models/pageflow/entry_publication.rb', line 16

def save!
  assumed_quota.verify_not_exceeded!
  entry.publish(attributes.merge(creator: user))
end