Class: Sunrise::Config::Association

Inherits:
Base
  • Object
show all
Defined in:
lib/sunrise/config/association.rb

Instance Attribute Summary

Attributes inherited from Base

#abstract_model, #name, #parent

Instance Method Summary collapse

Methods inherited from Base

#initialize, register_class_option, #register_instance_option, register_instance_option

Constructor Details

This class inherits a constructor from Sunrise::Config::Base

Instance Method Details

#is_this?(model_type) ⇒ Boolean

Compare relation by model_type

Returns:

  • (Boolean)


16
17
18
# File 'lib/sunrise/config/association.rb', line 16

def is_this?(model_type)
  [name.to_s, resource_name].map(&:downcase).include?(model_type.to_s.downcase)
end

#modelObject



11
12
13
# File 'lib/sunrise/config/association.rb', line 11

def model
  @model ||= Utils.lookup(resource_name.to_s.camelize)
end

#relation_nameObject



20
21
22
# File 'lib/sunrise/config/association.rb', line 20

def relation_name
  @relation_name ||= (@config_options[:relation_name] || abstract_model.model.model_name.plural)
end

#resource_nameObject



7
8
9
# File 'lib/sunrise/config/association.rb', line 7

def resource_name
  @resource_name ||= (@config_options[:class_name] || name)
end