Define instance method outside #included (#3128)

main
alpaca-tc 2017-05-19 18:41:45 +09:00 committed by Eugen Rochko
parent 6e4c7d6211
commit 198ae3e366
5 changed files with 103 additions and 105 deletions

View File

@ -20,6 +20,7 @@ module AccountAvatar
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-quality 80 -strip' }
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
validates_attachment_size :avatar, less_than: 2.megabytes
end
def avatar_original_url
avatar.url(:original)
@ -28,5 +29,4 @@ module AccountAvatar
def avatar_static_url
avatar_content_type == 'image/gif' ? avatar.url(:static) : avatar_original_url
end
end
end

View File

@ -20,6 +20,7 @@ module AccountHeader
has_attached_file :header, styles: ->(f) { header_styles(f) }, convert_options: { all: '-quality 80 -strip' }
validates_attachment_content_type :header, content_type: IMAGE_MIME_TYPES
validates_attachment_size :header, less_than: 2.megabytes
end
def header_original_url
header.url(:original)
@ -28,5 +29,4 @@ module AccountHeader
def header_static_url
header_content_type == 'image/gif' ? header.url(:static) : header_original_url
end
end
end

View File

@ -46,6 +46,7 @@ module AccountInteractions
has_many :muting, -> { order('mutes.id desc') }, through: :mute_relationships, source: :target_account
has_many :conversation_mutes, dependent: :destroy
has_many :domain_blocks, class_name: 'AccountDomainBlock', dependent: :destroy
end
def follow!(other_account)
active_relationships.find_or_create_by!(target_account: other_account)
@ -123,5 +124,4 @@ module AccountInteractions
def reblogged?(status)
status.proper.reblogs.where(account: self).exists?
end
end
end

View File

@ -6,6 +6,11 @@ module Streamable
included do
has_one :stream_entry, as: :activity
after_create do
account.stream_entries.create!(activity: self, hidden: hidden?) if needs_stream_entry?
end
end
def title
super
end
@ -30,12 +35,9 @@ module Streamable
false
end
private
def needs_stream_entry?
account.local?
end
after_create do
account.stream_entries.create!(activity: self, hidden: hidden?) if needs_stream_entry?
end
end
end

View File

@ -1,11 +1,7 @@
# frozen_string_literal: true
module Targetable
extend ActiveSupport::Concern
included do
def object_type
:object
end
end
end