Class: Stockboy::Attribute

Inherits:
Struct
  • Object
show all
Defined in:
lib/stockboy/attribute.rb

Overview

Struct-like value object for holding mapping & translation details from input data fields

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



6
7
8
# File 'lib/stockboy/attribute.rb', line 6

def from
  @from
end

#ignore_conditionObject

Returns the value of attribute ignore_condition

Returns:

  • (Object)

    the current value of ignore_condition



6
7
8
# File 'lib/stockboy/attribute.rb', line 6

def ignore_condition
  @ignore_condition
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



6
7
8
# File 'lib/stockboy/attribute.rb', line 6

def to
  @to
end

#translatorsObject

Returns the value of attribute translators

Returns:

  • (Object)

    the current value of translators



6
7
8
# File 'lib/stockboy/attribute.rb', line 6

def translators
  @translators
end

Instance Method Details

#ignore?(context) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
# File 'lib/stockboy/attribute.rb', line 7

def ignore?(context)
  if Symbol === ignore_condition
    context.public_send(to).public_send(ignore_condition)
  elsif ignore_condition.respond_to?(:call)
    ignore_condition.call(context)
  else
    !!(ignore_condition)
  end
end

#inspectObject



17
18
19
20
21
22
# File 'lib/stockboy/attribute.rb', line 17

def inspect
  "#<Stockboy::Attribute to=#{to.inspect}, from=#{from.inspect}%s%s>" % [
    (", translators=#{translators}" if translators),
    (", ignore=#{ignore_condition.inspect}" if ignore_condition)
  ]
end