Class: Moxml::NativeAttachment

Inherits:
Object
  • Object
show all
Defined in:
lib/moxml/native_attachment.rb,
lib/moxml/native_attachment/opal.rb,
lib/moxml/native_attachment/native.rb

Defined Under Namespace

Classes: Native, Opal

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backend: self.class.default_backend) ⇒ NativeAttachment

Returns a new instance of NativeAttachment.



15
16
17
# File 'lib/moxml/native_attachment.rb', line 15

def initialize(backend: self.class.default_backend)
  @backend = backend
end

Instance Attribute Details

#backendObject (readonly)

Returns the value of attribute backend.



13
14
15
# File 'lib/moxml/native_attachment.rb', line 13

def backend
  @backend
end

Class Method Details

.default_backendObject



8
9
10
11
# File 'lib/moxml/native_attachment.rb', line 8

def self.default_backend
  constant = RUBY_ENGINE == "opal" ? :Opal : :Native
  const_get(constant).new
end

Instance Method Details

#delete(native, key) ⇒ Object



31
32
33
# File 'lib/moxml/native_attachment.rb', line 31

def delete(native, key)
  @backend.delete(native, key)
end

#get(native, key) ⇒ Object



19
20
21
# File 'lib/moxml/native_attachment.rb', line 19

def get(native, key)
  @backend.get(native, key)
end

#key?(native, key) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/moxml/native_attachment.rb', line 27

def key?(native, key)
  @backend.key?(native, key)
end

#set(native, key, value) ⇒ Object



23
24
25
# File 'lib/moxml/native_attachment.rb', line 23

def set(native, key, value)
  @backend.set(native, key, value)
end