Class: ConvenientService::Common::Plugins::CanHaveUserProvidedEntity::Commands::FindOrCreateEntity
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Common::Plugins::CanHaveUserProvidedEntity::Commands::FindOrCreateEntity
- Defined in:
- lib/convenient_service/common/plugins/can_have_user_provided_entity/commands/find_or_create_entity.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#proto_entity ⇒ Object
readonly
Returns the value of attribute proto_entity.
Instance Method Summary collapse
Methods inherited from Support::Command
Constructor Details
#initialize(namespace:, proto_entity:) ⇒ void
26 27 28 29 |
# File 'lib/convenient_service/common/plugins/can_have_user_provided_entity/commands/find_or_create_entity.rb', line 26 def initialize(namespace:, proto_entity:) @namespace = namespace @proto_entity = proto_entity end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
13 14 15 |
# File 'lib/convenient_service/common/plugins/can_have_user_provided_entity/commands/find_or_create_entity.rb', line 13 def namespace @namespace end |
#proto_entity ⇒ Object (readonly)
Returns the value of attribute proto_entity.
19 20 21 |
# File 'lib/convenient_service/common/plugins/can_have_user_provided_entity/commands/find_or_create_entity.rb', line 19 def proto_entity @proto_entity end |
Instance Method Details
#call ⇒ void
This method returns an undefined value.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/convenient_service/common/plugins/can_have_user_provided_entity/commands/find_or_create_entity.rb', line 34 def call ::ConvenientService.raise Exceptions::ProtoEntityHasNoName.new(proto_entity: proto_entity) unless proto_entity_name ::ConvenientService.raise Exceptions::ProtoEntityHasNoConcern.new(proto_entity: proto_entity) unless proto_entity_concern entity.include Core entity.include proto_entity_concern ## # @example Result for service. # # klass = ConvenientService::Common::Plugins::CanHaveUserProvidedEntity::Commands::FindOrCreateEntity.call( # namespace: SomeService, # proto_entity: ConvenientService::Service::Plugins::HasJSendResult::Entities::Result # ) # # ## # # `klass` is something like: # # # # class Result < ConvenientService::Service::Plugins::HasJSendResult::Entities::Result # or just `class Result` if service (namespace) class defines its own. # # include ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Concern # (concern) # # # # class << self # # def proto_entity # # ## # # # NOTE: Returns `proto_entity` passed to `FindOrCreateEntity`. # # # # # proto_entity # # end # # # # def ==(other) # # return unless other.respond_to?(:proto_entity) # # # # self.proto_entity == other.proto_entity # # end # # end # # end # entity.class_exec(proto_entity) do |proto_entity| define_singleton_method(:proto_entity) { proto_entity } ## # @internal # TODO: Try `self.proto_entity == other.proto_entity if self < proto_entity_concern`. # define_singleton_method(:==) { |other| self.proto_entity == other.proto_entity if other.respond_to?(:proto_entity) } ## # TODO: `inspect`. # # define_singleton_method(:inspect) { "#{entity}(Prototyped by #{proto_entity})" } end entity end |