Module: Operations::ActAsOperationable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/operations/act_as_operationable.rb
Instance Method Summary collapse
Instance Method Details
#as_json(options = {}) ⇒ Object
22 23 24 |
# File 'lib/operations/act_as_operationable.rb', line 22 def as_json(={}) super.as_json().merge({scope: named_scope, operations: get_operations}) end |
#get_operations ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/operations/act_as_operationable.rb', line 8 def get_operations unless respond_to?(:operations) raise Operations::Errors::NotImplementedError.new(self.class, :operations) end unless self.operations.nil? || self.operations.class == String raise Operations::Errors::InvalidFieldError.new(:operations, self.class, String) end self.operations.to_s.to_operations end |
#named_scope ⇒ Object
18 19 20 |
# File 'lib/operations/act_as_operationable.rb', line 18 def named_scope Operations.user_role_name_from(role || 2) end |