Method: Hive::Broadcast.custom_json
- Defined in:
- lib/hive/broadcast.rb
.custom_json(options, &block) ⇒ Object
Serves the same purpose as custom but also supports required posting authorities.
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'lib/hive/broadcast.rb', line 842 def self.custom_json(, &block) required_fields = %i(id) params = [:params] if !!params[:data] && !!params[:json] raise Hive::ArgumentError, 'Assign either data or json, not both.' end data = params.delete(:data) || {} data ||= (JSON[params[:json]] || nil) || {} params[:json] = data.to_json check_required_fields(params, *required_fields) params[:required_auths] ||= [] params[:required_posting_auths] ||= [] ops = [[:custom_json, params]] process(.merge(ops: ops), &block) end |