Skip to content

Commit

Permalink
モンキーパッチの書き方を修正
Browse files Browse the repository at this point in the history
セットアップ方法のファイル修正
  • Loading branch information
Kenji Nagai committed Jul 9, 2017
1 parent 3c02e37 commit 5e82eee
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ MastodonCommand.setup do |status|

])
status = osaka.convert(status) if osaka.match(status)
status
end
```

Expand Down
4 changes: 3 additions & 1 deletion lib/mastodon_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "mastodon_command/convert"
require "mastodon_command/convert_random"
require "mastodon_command/convert_lang"
require "mastodon_command/statuses_controller"

module MastodonCommand
def self.setup(&proc)
Expand All @@ -18,6 +19,7 @@ class << self;
end

# Monkey patch
require "mastodon_command/statuses_controller"
Api::V1::StatusesController.prepend(ApiV1StatusesControllerPatch)
end
end

10 changes: 1 addition & 9 deletions lib/mastodon_command/statuses_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# モンキーパッチ
class Api::V1::StatusesController < Api::BaseController

module ApiV1StatusesControllerPatch
def create
status = MastodonCommand.convert_toot(status_params[:status])
@status = PostStatusService.new.call(current_user.account,
Expand All @@ -15,10 +13,4 @@ def create

render :show
end

private
# 使用されているprivateメソッドも入れておかないとモンキーパッチが動かなかった
def status_params
params.permit(:status, :in_reply_to_id, :sensitive, :spoiler_text, :visibility, media_ids: [])
end
end
2 changes: 1 addition & 1 deletion lib/mastodon_command/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module MastodonCommand
VERSION = "0.1.0"
VERSION = "0.1.1"
end

0 comments on commit 5e82eee

Please sign in to comment.