Class: Hive::Base
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Hive::Base
- Includes:
- SafeAttributes
- Defined in:
- lib/hive/models/base.rb
Overview
Abstract calss for all Hive active record classes.
Direct Known Subclasses
Account, Block, Community, FeedCache, Flag, Follow, Member, Modlog, Payment, Post, PostTag, PostsCache, Reblog, State
Class Method Summary collapse
-
.delete(_ = nil) ⇒ Object
Disabled.
-
.delete_all(_ = nil) ⇒ Object
Disabled.
-
.transform_account_selector(account) ⇒ Object
Uses ducktyping to query on account so that you can pass any type and still get a valid match.
-
.update_all(_ = nil) ⇒ Object
Disabled.
Instance Method Summary collapse
-
#delete(_ = nil) ⇒ Object
Disabled.
-
#update(*_) ⇒ Object
Disabled.
Class Method Details
.delete(_ = nil) ⇒ Object
Disabled
50 |
# File 'lib/hive/models/base.rb', line 50 def self.delete(_=nil); raise ActiveRecord::ReadOnlyRecord; end |
.delete_all(_ = nil) ⇒ Object
Disabled
53 |
# File 'lib/hive/models/base.rb', line 53 def self.delete_all(_=nil); raise ActiveRecord::ReadOnlyRecord; end |
.transform_account_selector(account) ⇒ Object
Uses ducktyping to query on account so that you can pass any type and still get a valid match.
So you can do:
Hive::Post.where(author: 'alice')
Hive::Post.where(author: %w(alice bob))
Hive::Post.where(author: Hive::Account.find_by_name('alice'))
Hive::Post.where(author: Hive::Account.where('name LIKE ?', '%z%'))
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/hive/models/base.rb', line 76 def self.transform_account_selector(account) case account when String then account when Array then account when Account then account.name else unless account.is_a? ActiveRecord::Relation raise "Don't know what to do with: #{account.class}" end account.select(:name) end end |
.update_all(_ = nil) ⇒ Object
Disabled
56 |
# File 'lib/hive/models/base.rb', line 56 def self.update_all(_=nil); raise ActiveRecord::ReadOnlyRecord; end |
Instance Method Details
#delete(_ = nil) ⇒ Object
Disabled
59 |
# File 'lib/hive/models/base.rb', line 59 def delete(_=nil); raise ActiveRecord::ReadOnlyRecord; end |
#update(*_) ⇒ Object
Disabled
62 |
# File 'lib/hive/models/base.rb', line 62 def update(*_); raise ActiveRecord::ReadOnlyRecord; end |