Class: Joblin::BackgroundTask::Options::TaskOptionsView

Inherits:
Object
  • Object
show all
Defined in:
app/models/joblin/background_task/options.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ TaskOptionsView

Returns a new instance of TaskOptionsView.



32
33
34
# File 'app/models/joblin/background_task/options.rb', line 32

def initialize(context)
  @context = context
end

Instance Method Details

#[](key) ⇒ Object



36
37
38
39
40
41
42
# File 'app/models/joblin/background_task/options.rb', line 36

def [](key)
  if @context.class.bt_passthrough_values.include?(key.to_s)
    @context.public_send(key.to_sym)
  else
    inner_hash[key]
  end
end

#[]=(key, value) ⇒ Object



44
45
46
47
48
49
50
# File 'app/models/joblin/background_task/options.rb', line 44

def []=(key, value)
  if @context.class.bt_passthrough_values.include?(key.to_s)
    @context.public_send("#{key.to_sym}=", value)
  else
    inner_hash[key] = value
  end
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
67
68
69
70
# File 'app/models/joblin/background_task/options.rb', line 64

def key?(key)
  if @context.class.bt_passthrough_values.include?(key.to_s)
    @context.public_send(key.to_sym).present?
  else
    inner_hash.key?(key)
  end
end

#keysObject



60
61
62
# File 'app/models/joblin/background_task/options.rb', line 60

def keys
  inner_hash.keys + @context.class.bt_passthrough_values
end

#merge(other) ⇒ Object



52
# File 'app/models/joblin/background_task/options.rb', line 52

def merge(other); to_h.merge!(other); end

#merge!(other) ⇒ Object



54
55
56
57
58
# File 'app/models/joblin/background_task/options.rb', line 54

def merge!(other)
  other.each do |k, v|
    self[k] = v
  end
end