Class: WorthSaving::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/worth_saving/info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, opts) ⇒ Info

Returns a new instance of Info.



5
6
7
8
# File 'lib/worth_saving/info.rb', line 5

def initialize(klass, opts)
  register_class klass
  set_up_options opts
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



3
4
5
# File 'lib/worth_saving/info.rb', line 3

def scope
  @scope
end

Class Method Details

.attribute_whitelisting_required?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/worth_saving/info.rb', line 14

def self.attribute_whitelisting_required?
  puts "Rails version: #{Rails.version}"
  puts "Defined?(ProtectedAttributes): #{defined?(ProtectedAttributes) == 'constant'}"
  result = Rails.version.match(/^3/).present? || defined?(ProtectedAttributes) == 'constant'
  puts "Returning: #{result}"
  result
end

.class_with_name(name) ⇒ Object



10
11
12
# File 'lib/worth_saving/info.rb', line 10

def self.class_with_name(name)
  classes.find{ |klass| klass.name == name.camelcase }
end

Instance Method Details

#saves_field?(field) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/worth_saving/info.rb', line 22

def saves_field?(field)
  !@excluded_fields.include? field
end