Class: Jot::Ruby::ImplBase

Inherits:
Object
  • Object
show all
Extended by:
Utils::Snippets
Defined in:
lib/jot/ruby/impl_base.rb

Defined Under Namespace

Modules: Prepender

Constant Summary collapse

RAW_METHODS =
%i[opFromJSON deserialize diff].freeze
DEFAULT_OPERATIONS =
[
  :NO_OP,                   # Does nothing
  :SET, :LIST,              # General operations
  :MATH,                    # Math
  :SPLICE, :ATINDEX, :MAP,  # Stings and Arrays
  :PUT, :REM, :APPLY,       # Object operations
  :COPY                     # Affect structure
].freeze
DEFAULT_METHODS =
RAW_METHODS + DEFAULT_OPERATIONS

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Utils::Snippets

gem_root, not_implemented

Class Attribute Details

.registry_keyObject

Returns the value of attribute registry_key.



7
8
9
# File 'lib/jot/ruby/impl_base.rb', line 7

def registry_key
  @registry_key
end

Class Method Details

.inherited(base) ⇒ Object



16
17
18
19
20
21
# File 'lib/jot/ruby/impl_base.rb', line 16

def inherited(base)
  super
  base.prepend Prepender
  base.registry_key = SecureRandom.hex
  ::Jot::Ruby.impl_registry[base.registry_key] = base
end

.operation_classObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jot/ruby/impl_base.rb', line 24

def self.operation_class
  @operation_class ||= begin
    klass = Class.new(Operation)
    if self.constants.include? :OperationMethods
      klass.include self::OperationMethods
    else
      raise Errors::NoImplError, "impl has no OperationMethods module"
    end
    klass.prepend Operation::OriginalOperationMethods
    klass
  end
end