class GlobalRegistry::Bindings::Options::EntityInstanceOptions

Public Class Methods

new(model) click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 17
def initialize(model)
  @model = model
  @class_options = model.class.global_registry_entity
end

Public Instance Methods

condition?(cond) click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 88
def condition?(cond)
  option = @class_options.send(cond)
  case option
  when Proc
    option.call(@model)
  when Symbol
    @model.send(option, @model)
  else
    :if != cond
  end
end
exclude() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 64
def exclude
  option = @class_options.exclude
  case option
  when Proc
    option.call(type, @model)
  when Symbol
    @model.send(option, type)
  else
    option
  end
end
fields() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 76
def fields
  option = @class_options.fields
  case option
  when Proc
    option.call(type, @model)
  when Symbol
    @model.send(option, type)
  else
    option
  end
end
id_value() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 22
def id_value
  @model.send id_column
end
id_value=(value) click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 26
def id_value=(value)
  @model.send "#{id_column}=", value
end
id_value?() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 30
def id_value?
  @model.send "#{id_column}?"
end
parent() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 39
def parent
  @model.send(@class_options.parent) if @class_options.parent.present?
end
parent_class() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 43
def parent_class
  return if @class_options.parent.blank?
  @class_options.parent_class
end
parent_id_value() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 52
def parent_id_value
  parent&.global_registry_entity&.id_value
end
parent_is_self?() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 60
def parent_is_self?
  @class_options.parent.present? && parent_class == @model.class
end
parent_required?() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 56
def parent_required?
  @class_options.parent.present? && !parent_is_self?
end
parent_type() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 48
def parent_type
  parent&.global_registry_entity&.type
end
type() click to toggle source
# File lib/global_registry_bindings/options/entity_instance_options.rb, line 34
def type
  t = @class_options.type
  t.is_a?(Proc) ? t.call(@model) : t
end