Module: Radiator::Mixins::ActsAsPoster
- Included in:
- Chain
- Defined in:
- lib/radiator/mixins/acts_as_poster.rb
Instance Method Summary collapse
-
#delete_comment(permlink) ⇒ Object
Create a delete_comment operation.
-
#delete_comment!(permlink) ⇒ Object
Create a delete_comment operation and broadcasts it right away.
-
#post(options = {}) ⇒ Object
Creates a post operation.
-
#post!(options = {}) ⇒ Object
Create a vote operation and broadcasts it right away.
Instance Method Details
#delete_comment(permlink) ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/radiator/mixins/acts_as_poster.rb', line 103 def delete_comment(permlink) @operations << { type: :delete_comment, author: account_name, permlink: permlink } self end |
#delete_comment!(permlink) ⇒ Object
121 |
# File 'lib/radiator/mixins/acts_as_poster.rb', line 121 def delete_comment!(permlink); delete_comment(permlink).broadcast!(true); end |
#post(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/radiator/mixins/acts_as_poster.rb', line 26 def post( = {}) = [[:tags] || []].flatten title = [:title].to_s permlink = [:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-') parent_permlink = [:parent_permlink] || [0] raise ChainError, 'At least one tag is required or set the parent_permlink directy.' if parent_permlink.nil? body = [:body] = [:parent_author] || '' max_accepted_payout = [:max_accepted_payout] || default_max_acepted_payout percent_hbd = [:percent_hbd] allow_votes = [:allow_votes] || true allow_curation_rewards = [:allow_curation_rewards] || true self_vote = [:self_vote] .insert(0, parent_permlink) = .compact.uniq = { app: Radiator::AGENT_ID } [:tags] = if .any? @operations << { type: :comment, parent_permlink: parent_permlink, author: account_name, permlink: permlink, title: title, body: body, json_metadata: .to_json, parent_author: } if (!!max_accepted_payout && max_accepted_payout != default_max_acepted_payout ) || !!percent_hbd || !allow_votes || !allow_curation_rewards @operations << { type: :comment_options, author: account_name, permlink: permlink, max_accepted_payout: max_accepted_payout, percent_hbd: percent_hbd, allow_votes: allow_votes, allow_curation_rewards: allow_curation_rewards, extensions: [] } end vote(self_vote, account_name, permlink) if !!self_vote self end |
#post!(options = {}) ⇒ Object
92 |
# File 'lib/radiator/mixins/acts_as_poster.rb', line 92 def post!( = {}); post().broadcast!(true); end |