Created
December 1, 2016 02:41
-
-
Save tntdev21/4be07479bfdc1e8b32b35ee491f618ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ZillyBuck | |
extend ActiveSupport::Concern | |
def create_reimburement_attachment_reward(owner) | |
kind = :add_an_reimburement_attachment | |
amount = ZillyBuckHistory::REWARD_AMOUNT[:add_an_reimburement_attachment] | |
create_history_if_need(owner, kind, amount) | |
end | |
def create_approval_attachment_reward(owner) | |
kind = :add_an_approval_attachment | |
amount = ZillyBuckHistory::REWARD_AMOUNT[:add_an_approval_attachment] | |
create_history_if_need(owner, kind, amount) | |
end | |
def create_invite_friend_reward(owner) | |
kind = :invite_friend | |
amount = ZillyBuckHistory::REWARD_AMOUNT[:invite_friend] | |
create_history_if_need(owner, kind, amount) | |
end | |
private | |
def create_history_if_need(owner, kind, amount) | |
create_history if owner.can_receive_reward?(kind) | |
end | |
def create_history(owner, kind, amount) | |
owner.zilly_buck_histories.create!(kind: kind, amount: amount) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment