Commit 2ad14cc2d602051500be69e71764b95d54009f55
1 parent
b5fd9cb4
Exists in
ratings_minor_fixes
and in
4 other branches
plugins api: don't reinherit class on extension
Showing
2 changed files
with
19 additions
and
17 deletions
Show diff stats
plugins/comment_paragraph/lib/ext/entities.rb
plugins/statistics/lib/ext/entities.rb
1 | 1 | require_dependency 'api/entities' |
2 | 2 | |
3 | -module Entities | |
4 | - class Block < Api::Entity | |
5 | - available_counters = (StatisticsBlock::USER_COUNTERS + StatisticsBlock::COMMUNITY_COUNTERS + StatisticsBlock::ENTERPRISE_COUNTERS).uniq | |
6 | - expose :statistics, :if => lambda { |block, options| block.is_a? StatisticsBlock } do |block, options| | |
7 | - statistics = [] | |
8 | - available_counters.each do |counter_attr| | |
9 | - counter_method = counter_attr.to_s.gsub('_counter','').pluralize.to_sym | |
10 | - counter = { | |
11 | - name: counter_method, | |
12 | - display: block.is_counter_available?(counter_attr) && block.is_visible?(counter_attr), | |
13 | - quantity: (block.respond_to?(counter_method) && block.is_visible?(counter_attr)) ? block.send(counter_method) : nil | |
14 | - } | |
15 | - statistics << counter | |
3 | +module Api | |
4 | + module Entities | |
5 | + class Block | |
6 | + available_counters = (StatisticsBlock::USER_COUNTERS + StatisticsBlock::COMMUNITY_COUNTERS + StatisticsBlock::ENTERPRISE_COUNTERS).uniq | |
7 | + expose :statistics, :if => lambda { |block, options| block.is_a? StatisticsBlock } do |block, options| | |
8 | + statistics = [] | |
9 | + available_counters.each do |counter_attr| | |
10 | + counter_method = counter_attr.to_s.gsub('_counter','').pluralize.to_sym | |
11 | + counter = { | |
12 | + name: counter_method, | |
13 | + display: block.is_counter_available?(counter_attr) && block.is_visible?(counter_attr), | |
14 | + quantity: (block.respond_to?(counter_method) && block.is_visible?(counter_attr)) ? block.send(counter_method) : nil | |
15 | + } | |
16 | + statistics << counter | |
17 | + end | |
18 | + statistics | |
16 | 19 | end |
17 | - statistics | |
18 | - end | |
19 | 20 | |
21 | + end | |
20 | 22 | end |
21 | 23 | end | ... | ... |