Sprinkle frozen string literal & Indentation Fix (#150)

* Avoid extra string alocation as join will always return string

* Fix indentation

* Sprinkle frozen string literal true
This commit is contained in:
Akshay Birajdar
2019-10-16 12:22:30 +05:30
committed by Sojan Jose
parent 59e9fbd336
commit a1452d7d89
18 changed files with 63 additions and 36 deletions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Constants::Report
ACCOUNT_METRICS = [ :conversations_count,
:incoming_messages_count,

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module CustomExceptions::Account
class InvalidEmail < CustomExceptions::Base

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CustomExceptions::Base < ::StandardError
def to_hash

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module CustomExceptions::Report
class InvalidIdentity < CustomExceptions::Base
def message

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Events::Types
CONVERSATION_CREATED = 'conversation.created'
CONVERSATION_RESOLVED = 'conversation.resolved'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Integrations::Facebook::DeliveryStatus
def initialize(params)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Integrations::Facebook::MessageCreator
attr_reader :response
@@ -28,8 +30,8 @@ class Integrations::Facebook::MessageCreator
def create_outgoing_message
FacebookPage.where(page_id: response.sender_id).each do |page|
mb = Messages::Outgoing::EchoBuilder.new(response, page.inbox, true)
mb.perform
mb = Messages::Outgoing::EchoBuilder.new(response, page.inbox, true)
mb.perform
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Integrations::Facebook::MessageParser
def initialize(response_json)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Integrations::Widget::IncomingMessageBuilder
# params = {
# contact_id: 1,

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Integrations::Widget::OutgoingMessageBuilder
# params = {
# user_id: 1,

View File

@@ -1,38 +1,38 @@
class LocalResource
attr_reader :uri
attr_reader :uri
def initialize(uri)
@uri = uri
end
def initialize(uri)
@uri = uri
end
def file
@file ||= Tempfile.new(tmp_filename, tmp_folder, encoding: encoding).tap do |f|
io.rewind
f.write(io.read)
f.close
end
end
def file
@file ||= Tempfile.new(tmp_filename, tmp_folder, encoding: encoding).tap do |f|
io.rewind
f.write(io.read)
f.close
end
end
def io
@io ||= uri.open
end
def io
@io ||= uri.open
end
def encoding
io.rewind
io.read.encoding
end
def encoding
io.rewind
io.read.encoding
end
def tmp_filename
[
Time.now.to_i.to_s,
Pathname.new(uri.path).extname
]
end
def tmp_filename
[
Time.now.to_i.to_s,
Pathname.new(uri.path).extname
]
end
def tmp_folder
# If we're using Rails:
Rails.root.join('tmp')
# Otherwise:
# '/wherever/you/want'
end
def tmp_folder
# If we're using Rails:
Rails.root.join('tmp')
# Otherwise:
# '/wherever/you/want'
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Reports::UpdateAccountIdentity < Reports::UpdateIdentity
attr_reader :account

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Reports::UpdateAgentIdentity < Reports::UpdateIdentity
attr_reader :agent

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Reports::UpdateIdentity
attr_reader :account, :identity

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Webhooks::Chargebee
SUPPORTED_EVENTS = [:subscription_created, :subscription_trial_end_reminder,