Module: ActsAsCitable

Defined in:
lib/acts_as_citable/base.rb,
lib/acts_as_citable/version.rb

Defined Under Namespace

Modules: InstanceMethods

Constant Summary collapse

VERSION =
"5.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#data_fieldObject

Returns the value of attribute data_field.



3
4
5
# File 'lib/acts_as_citable/base.rb', line 3

def data_field
  @data_field
end

#format_fieldObject

Returns the value of attribute format_field.



3
4
5
# File 'lib/acts_as_citable/base.rb', line 3

def format_field
  @format_field
end

Instance Method Details

#acts_as_citable(&block) ⇒ Object

Hooks into an object to define its ‘format’ and ‘data’ fields. These are used to translate into other forms of metadata.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/acts_as_citable/base.rb', line 8

def acts_as_citable &block
  # Allow for configurations
  self.format_field = 'format'
  self.data_field = 'data'
  if block
    yield self
  end

  # Use procs to define methods that give the data_field and format_field for inherited models.
  format_string = "#{self.format_field}"
  data_string = "#{self.data_field}"

  define_method(:format_field,  Proc.new {format_string} )
  define_method(:data_field, Proc.new {data_string} )
  # Include the instance methods found below
  include InstanceMethods
end