Sha256: 9efedc8dff4218a3db692ae24e0074f9e45588acdf8d7a0de064e08b20e4665f
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require 'clowne/ext/string_constantize' module Clowne module Declarations class IncludeAssociation < Base # :nodoc: all using Clowne::Ext::StringConstantize attr_accessor :name, :scope, :options def initialize(name, scope = nil, **options) @name = name.to_sym @scope = scope @options = options end def compile(plan) plan.add_to(:association, name, self) end def matches?(names) names = Array(names) names.include?(name) end def params_proxy @_params_proxy ||= Clowne::Utils::Params.proxy(options[:params]) end def params options[:params] end def clone_with return @clone_with if instance_variable_defined?(:@clone_with) @clone_with = case options[:clone_with] when String, Symbol options[:clone_with].to_s.constantize else options[:clone_with] end end def traits options[:traits] end end end end Clowne::Declarations.add :include_association, Clowne::Declarations::IncludeAssociation Clowne::Declarations.add :include_associations do |*names| names.each do |name| declarations.push Clowne::Declarations::IncludeAssociation.new(name) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clowne-1.1.0 | lib/clowne/declarations/include_association.rb |
clowne-1.0.0 | lib/clowne/declarations/include_association.rb |