Sha256: fc7a6213d57a844ba7091793582918dfb585673b9061ea194f116160f097a66b
Contents?: true
Size: 447 Bytes
Versions: 1
Compression:
Stored size: 447 Bytes
Contents
# frozen_string_literal: true module InertiaRails class LazyProp < BaseProp def initialize(value = nil, &block) raise ArgumentError, 'You must provide either a value or a block, not both' if value && block @value = value @block = block end def call(controller) value.respond_to?(:call) ? controller.instance_exec(&value) : value end def value @value.nil? ? @block : @value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inertia_rails-3.5.0 | lib/inertia_rails/lazy_prop.rb |