Class: Cubism::BlockContainer

Inherits:
Struct
  • Object
show all
Defined in:
lib/cubism/cubicle_store.rb

Overview

Container for cubicle blocks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ BlockContainer

Returns a new instance of BlockContainer.



55
56
57
58
59
# File 'lib/cubism/cubicle_store.rb', line 55

def initialize(*args)
  super

  @filename, _lineno = block_location.split(":")
end

Instance Attribute Details

#block_locationObject

Returns the value of attribute block_location

Returns:

  • (Object)

    the current value of block_location



47
48
49
# File 'lib/cubism/cubicle_store.rb', line 47

def block_location
  @block_location
end

#block_sourceObject

Returns the value of attribute block_source

Returns:

  • (Object)

    the current value of block_source



47
48
49
# File 'lib/cubism/cubicle_store.rb', line 47

def block_source
  @block_source
end

#resource_gidObject

Returns the value of attribute resource_gid

Returns:

  • (Object)

    the current value of resource_gid



47
48
49
# File 'lib/cubism/cubicle_store.rb', line 47

def resource_gid
  @resource_gid
end

#scopeObject

Returns the value of attribute scope

Returns:

  • (Object)

    the current value of scope



47
48
49
# File 'lib/cubism/cubicle_store.rb', line 47

def scope
  @scope
end

#user_gidObject

Returns the value of attribute user_gid

Returns:

  • (Object)

    the current value of user_gid



47
48
49
# File 'lib/cubism/cubicle_store.rb', line 47

def user_gid
  @user_gid
end

Instance Method Details

#digestObject



73
74
75
76
77
# File 'lib/cubism/cubicle_store.rb', line 73

def digest
  resource_user_key = [resource_gid, user_gid, scope].join(":")

  ActiveSupport::Digest.hexdigest("#{block_location}:#{File.read(@filename)}:#{resource_user_key}")
end

#marshal_dumpObject



79
80
81
# File 'lib/cubism/cubicle_store.rb', line 79

def marshal_dump
  to_h.merge(block_source: block_source.digest)
end

#marshal_load(serialized_item) ⇒ Object



83
84
85
86
87
88
89
# File 'lib/cubism/cubicle_store.rb', line 83

def marshal_load(serialized_item)
  members.excluding(:block_source).each do |arg|
    send("#{arg}=", serialized_item[arg])
  end

  self.block_source = Cubism.source_store[serialized_item[:block_source]]
end

#resourceObject



65
66
67
# File 'lib/cubism/cubicle_store.rb', line 65

def resource
  GlobalID::Locator.locate self[:resource_gid]
end

#userObject



61
62
63
# File 'lib/cubism/cubicle_store.rb', line 61

def user
  GlobalID::Locator.locate self[:user_gid]
end