class Vue::Helpers::VueRepository

Stores ruby representations of vue objects. Intended for a single request cycle. TODO: Rename this to VueStash. NOTE: Always use the repository interface for vue-object crud operations from controller or views.

Attributes

context[R]

Public Class Methods

new(context) click to toggle source

Always pass a context when creating a VueRepository.

# File lib/vue/helpers/vue_repository.rb, line 22
def initialize(context)
  #Debug << self
  @context = context
end

Public Instance Methods

component(name, **options) click to toggle source

Gets or creates a VueComponent instance.

# File lib/vue/helpers/vue_repository.rb, line 43
def component(name, **options)
  get_or_create(VueComponent, name, **options)
end
get_or_create(klas, name, **options) click to toggle source

Master get_or_create for any object in the repository.

# File lib/vue/helpers/vue_repository.rb, line 28
def get_or_create(klas, name, **options)
  obj = fetch(name){ |n| self[name] = klas.new(name, **options.merge({repo:self})) }
  obj.repo ||= self
  obj.initialize_options(**options)
  obj
end
root(name=nil, **options) click to toggle source

Gets or creates a VueRoot instance.

# File lib/vue/helpers/vue_repository.rb, line 36
def root(name=nil, **options)
  name ||= Vue::Helpers.root_name
  get_or_create(VueRoot, name, **options)
end