Class: ActiveRecord::Bixformer::Attribute::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord-bixformer/attribute/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, attribute_name, options) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
# File 'lib/activerecord-bixformer/attribute/base.rb', line 7

def initialize(model, attribute_name, options)
  @model   = model
  @name    = attribute_name.to_s
  @options = (options.is_a?(::Hash) ? options : {}).with_indifferent_access

  @options[:raise] = true unless @options.key?(:raise)
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/activerecord-bixformer/attribute/base.rb', line 5

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/activerecord-bixformer/attribute/base.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/activerecord-bixformer/attribute/base.rb', line 5

def options
  @options
end

Instance Method Details

#export(record) ⇒ Object



15
16
17
# File 'lib/activerecord-bixformer/attribute/base.rb', line 15

def export(record)
  record_attribute_value(record)
end

#import(value) ⇒ Object



19
20
21
# File 'lib/activerecord-bixformer/attribute/base.rb', line 19

def import(value)
  value
end

#should_be_includedObject



23
24
25
# File 'lib/activerecord-bixformer/attribute/base.rb', line 23

def should_be_included
  nil
end