Class: HasOne

Inherits:
Struct show all
Defined in:
lib/mailroute/extensions/active_resource/has_one.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#klassObject

Returns the value of attribute klass

Returns:

  • (Object)

    the current value of klass



1
2
3
# File 'lib/mailroute/extensions/active_resource/has_one.rb', line 1

def klass
  @klass
end

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



1
2
3
# File 'lib/mailroute/extensions/active_resource/has_one.rb', line 1

def model
  @model
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



1
2
3
# File 'lib/mailroute/extensions/active_resource/has_one.rb', line 1

def options
  @options
end

Instance Method Details

#foreign_classObject



6
7
8
# File 'lib/mailroute/extensions/active_resource/has_one.rb', line 6

def foreign_class
  options[:class] || Mailroute.const_get(ActiveSupport::Inflector.classify(model))
end

#inverseObject



2
3
4
# File 'lib/mailroute/extensions/active_resource/has_one.rb', line 2

def inverse
  ActiveSupport::Inflector.underscore(klass.to_s.split('::').last)
end

#pkObject



10
11
12
# File 'lib/mailroute/extensions/active_resource/has_one.rb', line 10

def pk
  options[:pk]
end