Class: ReactiveRecord::Base::DummyValue

Inherits:
NilClass
  • Object
show all
Defined in:
lib/reactive_record/active_record/reactive_record/isomorphic_base.rb

Instance Method Summary collapse

Constructor Details

#initializeDummyValue

Returns a new instance of DummyValue.



118
119
120
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 118

def initialize()
  notify
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 122

def method_missing(method, *args, &block)
  if 0.respond_to? method
    notify
    0.send(method, *args, &block)
  elsif "".respond_to? method
    notify
    "".send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#==(other_value) ⇒ Object



146
147
148
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 146

def ==(other_value)
  other_value.object_id == self.object_id
end

#acts_as_string?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 180

def acts_as_string?
  true
end

#coerce(s) ⇒ Object



142
143
144
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 142

def coerce(s)
  [self.send("to_#{s.class.name.downcase}"), s]
end

#loading?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 134

def loading?
  true
end

#notifyObject



111
112
113
114
115
116
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 111

def notify
  unless ReactiveRecord::Base.data_loading?
    ReactiveRecord.loads_pending!           #loads
    ReactiveRecord::WhileLoading.loading!   #loads
  end
end

#present?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 138

def present?
  false
end

#to_dateObject



175
176
177
178
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 175

def to_date
  notify
  "2001-01-01T00:00:00.000-00:00".to_date
end

#to_fObject



155
156
157
158
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 155

def to_f
  notify
  0.0
end

#to_iObject



160
161
162
163
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 160

def to_i
  notify
  0
end

#to_numberObject



170
171
172
173
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 170

def to_number
  notify
  0
end

#to_numericObject



165
166
167
168
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 165

def to_numeric
  notify
  0
end

#to_sObject



150
151
152
153
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 150

def to_s
  notify
  ""
end

#try(*args, &b) ⇒ Object



184
185
186
187
188
189
190
191
192
# File 'lib/reactive_record/active_record/reactive_record/isomorphic_base.rb', line 184

def try(*args, &b)
  if args.empty? && block_given?
    yield self
  else
    send(*args, &b)
  end
rescue
  nil
end