Class: Backstage::AssociationConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/backstage/association_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, kind, options = {}) ⇒ AssociationConfig

Returns a new instance of AssociationConfig.



5
6
7
8
9
# File 'lib/backstage/association_config.rb', line 5

def initialize(name, kind, options = {})
  @name = name.to_sym
  @kind = kind.to_sym
  @options = options
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



3
4
5
# File 'lib/backstage/association_config.rb', line 3

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/backstage/association_config.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/backstage/association_config.rb', line 3

def options
  @options
end

Instance Method Details

#associated_classObject



23
24
25
# File 'lib/backstage/association_config.rb', line 23

def associated_class
  class_name.constantize
end

#class_nameObject



19
20
21
# File 'lib/backstage/association_config.rb', line 19

def class_name
  options[:class_name] || name.to_s.classify
end

#display_columnObject



11
12
13
# File 'lib/backstage/association_config.rb', line 11

def display_column
  options[:display_column] || :id
end

#foreign_keyObject



15
16
17
# File 'lib/backstage/association_config.rb', line 15

def foreign_key
  options[:foreign_key] || :"#{name}_id"
end

#image_colObject



27
28
29
# File 'lib/backstage/association_config.rb', line 27

def image_col
  options[:image_col] || :url
end