Class: SBF::Client::Permissions

Inherits:
BaseEntity show all
Defined in:
lib/stbaldricks/entities/lib/permissions.rb

Constant Summary

Constants inherited from BaseEntity

BaseEntity::ELSE

Instance Attribute Summary collapse

Attributes inherited from BaseEntity

#errors

Instance Method Summary collapse

Methods inherited from BaseEntity

allow_instantiation?, attr_accessor, attr_reader, attr_writer, collection_attributes, defined_attributes, #destroyed?, #dirty_data, entity_attr_accessor, entity_attr_reader, entity_attr_writer, entity_attributes, entity_collection_attr_accessor, entity_collection_attr_reader, entity_collection_attr_writer, #error, inherited, #initialize, #keys_hash, #model_name, multitype_attr_accessor, multitype_attr_reader, multitype_attr_writer, multitype_collection_attr_accessor, multitype_collection_attr_reader, multitype_collection_attr_writer, #not_provided_attributes, optional_attributes, #persisted?, #reload!, #reload_recursive, #rollback!, #to_hash, #to_json, #to_partial

Methods included from EntityResponseConcern

#add_errors, #data, #error?, #errors?, #errors_http_code=, #http_code, #success?

Constructor Details

This class inherits a constructor from SBF::Client::BaseEntity

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object

rubocop:disable Style/MissingRespondToMissing



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stbaldricks/entities/lib/permissions.rb', line 12

def method_missing(method, *arguments, &block)
  # If the method starts with 'can', assume they are trying to determine if the user has the permission
  # in their list of permission ids and return the result
  if method.to_s.start_with?('can_')
    const_name = method.to_s.split('can_').last.upcase.to_sym

    if SBF::Client::Permission.constants(false).include?(const_name)
      permission_id = SBF::Client::Permission.const_get(const_name, false)
      return permission_ids.include?(permission_id)

    end
  end

  super
end

Instance Attribute Details

#is_ownerObject

Returns the value of attribute is_owner.



8
9
10
# File 'lib/stbaldricks/entities/lib/permissions.rb', line 8

def is_owner
  @is_owner
end

#permission_idsObject

Returns the value of attribute permission_ids.



9
10
11
# File 'lib/stbaldricks/entities/lib/permissions.rb', line 9

def permission_ids
  @permission_ids
end