Class: AdLocalize::Requests::MergePolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/ad_localize/requests/merge_policy.rb

Constant Summary collapse

REPLACE_POLICY =
'replace'.freeze
KEEP_POLICY =
'keep'.freeze
MERGE_POLICIES =
[KEEP_POLICY, REPLACE_POLICY]
DEFAULT_POLICY =
KEEP_POLICY

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(policy:) ⇒ MergePolicy

Returns a new instance of MergePolicy.



11
12
13
# File 'lib/ad_localize/requests/merge_policy.rb', line 11

def initialize(policy:)
  @policy = policy
end

Instance Attribute Details

#policyObject (readonly)

Returns the value of attribute policy.



9
10
11
# File 'lib/ad_localize/requests/merge_policy.rb', line 9

def policy
  @policy
end

Instance Method Details

#keep?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ad_localize/requests/merge_policy.rb', line 15

def keep?
  @policy == KEEP_POLICY
end

#replace?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ad_localize/requests/merge_policy.rb', line 19

def replace?
  @policy == REPLACE_POLICY
end

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ad_localize/requests/merge_policy.rb', line 23

def valid?
  @policy.present? && MERGE_POLICIES.include?(@policy)
end