Module: Sipity
- Defined in:
- app/models/sipity.rb,
app/models/sipity/role.rb,
app/models/sipity/agent.rb,
app/models/sipity/entity.rb,
app/models/sipity/method.rb,
app/models/sipity/comment.rb,
app/models/sipity/workflow.rb,
app/models/sipity/notification.rb,
app/models/sipity/workflow_role.rb,
app/models/sipity/workflow_state.rb,
app/models/sipity/workflow_action.rb,
app/models/sipity/notifiable_context.rb,
app/models/sipity/workflow_state_action.rb,
app/models/sipity/notification_recipient.rb,
app/models/sipity/workflow_responsibility.rb,
app/models/sipity/entity_specific_responsibility.rb,
app/models/sipity/workflow_state_action_permission.rb
Defined Under Namespace
Classes: Agent, Comment, ConversionError, Entity, EntitySpecificResponsibility, Method, NotifiableContext, Notification, NotificationRecipient, Role, StateError, Workflow, WorkflowAction, WorkflowResponsibility, WorkflowRole, WorkflowState, WorkflowStateAction, WorkflowStateActionPermission
Class Method Summary collapse
-
.Agent(input, &block) ⇒ Object
rubocop:disable Naming/MethodName.
-
.Entity(input, &block) ⇒ Object
Cast an object to an Entity rubocop:disable Naming/MethodName, Metrics/CyclomaticComplexity, Metrics/MethodLength.
-
.handle_conversion(input, result, method_name) ⇒ Object
Provides compatibility with the old ‘PowerConverter` conventions.
-
.Role(input, &block) ⇒ Object
Cast an object to an Role.
-
.WorkflowAction(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowAction in a given workflow.
-
.WorkflowState(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowState in a given workflow.
Class Method Details
.Agent(input, &block) ⇒ Object
rubocop:disable Naming/MethodName
4 5 6 7 8 9 10 11 |
# File 'app/models/sipity.rb', line 4 def Agent(input, &block) # rubocop:disable Naming/MethodName result = case input when Sipity::Agent input end handle_conversion(input, result, :to_sipity_agent, &block) end |
.Entity(input, &block) ⇒ Object
Cast an object to an Entity rubocop:disable Naming/MethodName, Metrics/CyclomaticComplexity, Metrics/MethodLength
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/sipity.rb', line 17 def Entity(input, &block) result = case input when Sipity::Entity input when URI::GID, GlobalID Entity.find_by(proxy_for_global_id: input.to_s) when SolrDocument Entity(input.to_model) when Draper::Decorator Entity(input.model) when Sipity::Comment Entity(input.entity) when Valkyrie::Resource Entity(Hyrax::GlobalID(input)) else Entity(input.to_global_id) if input.respond_to?(:to_global_id) end handle_conversion(input, result, :to_sipity_entity, &block) rescue URI::GID::MissingModelIdError Entity(nil) end |
.handle_conversion(input, result, method_name) ⇒ Object
Provides compatibility with the old ‘PowerConverter` conventions
100 101 102 103 104 105 106 |
# File 'app/models/sipity.rb', line 100 def handle_conversion(input, result, method_name) result ||= input.try(method_name) return result unless result.nil? return yield if block_given? raise ConversionError.new(input) # rubocop:disable Style/RaiseArgs end |
.Role(input, &block) ⇒ Object
Cast an object to an Role
44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/sipity.rb', line 44 def Role(input, &block) # rubocop:disable Naming/MethodName result = case input when Sipity::Role input when String, Symbol Sipity::Role.find_or_create_by(name: input) end handle_conversion(input, result, :to_sipity_role, &block) end |
.WorkflowAction(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowAction in a given workflow
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/sipity.rb', line 58 def WorkflowAction(input, workflow, &block) # rubocop:disable Naming/MethodName workflow_id = PowerConverter.convert_to_sipity_workflow_id(workflow) result = case input when WorkflowAction input if input.workflow_id == workflow_id when String, Symbol WorkflowAction.find_by(workflow_id: workflow_id, name: input.to_s) end handle_conversion(input, result, :to_sipity_action, &block) end |
.WorkflowState(input, workflow, &block) ⇒ Object
Cast an object to a WorkflowState in a given workflow
74 75 76 77 78 79 80 81 82 83 |
# File 'app/models/sipity.rb', line 74 def WorkflowState(input, workflow, &block) # rubocop:disable Naming/MethodName result = case input when Sipity::WorkflowState input when Symbol, String WorkflowState.find_by(workflow_id: workflow.id, name: input) end handle_conversion(input, result, :to_sipity_workflow_state, &block) end |