Define instance method outside #included (#3128)

This commit is contained in:
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)
@ -29,4 +30,3 @@ module AccountAvatar
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)
@ -29,4 +30,3 @@ module AccountHeader
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)
@ -124,4 +125,3 @@ module AccountInteractions
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