Sha256: e46c7b0d19aea12a4007ca47f9123415c1ad78cb1ff75bc87b67c835b4f94491
Contents?: true
Size: 936 Bytes
Versions: 1
Compression:
Stored size: 936 Bytes
Contents
module InertiaRails mattr_accessor :shared_plain_data, default: {} mattr_accessor :shared_blocks, default: [] def self.configure yield(Configuration) end # "Getters" def self.shared_data(controller) shared_plain_data.merge!(evaluated_blocks(controller, shared_blocks)) end def self.version Configuration.evaluated_version end def self.layout Configuration.layout end # "Setters" def self.share(**args) shared_plain_data.merge!(args) end def self.share_block(block) shared_blocks.push(block) end private module Configuration mattr_accessor :layout, default: 'application' mattr_accessor :version, default: nil def self.evaluated_version version.respond_to?(:call) ? version.call : version end end def self.evaluated_blocks(controller, blocks) blocks.flat_map { |block| controller.instance_exec(&block) }.reduce(&:merge) || {} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inertia_rails-1.0.1 | lib/inertia_rails/inertia_rails.rb |