Class: ActiveGist::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/active_gist/files.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Files

Returns a new instance of Files.



6
7
8
9
# File 'lib/active_gist/files.rb', line 6

def initialize(hash = {})
  @hash = hash
  @changed = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



22
23
24
# File 'lib/active_gist/files.rb', line 22

def method_missing(name, *args, &block)
  hash.send name, *args, &block
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



2
3
4
# File 'lib/active_gist/files.rb', line 2

def hash
  @hash
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/active_gist/files.rb', line 11

def changed?
  @hash_copy != hash
end

#replace_with(hash) ⇒ Object



15
16
17
18
19
20
# File 'lib/active_gist/files.rb', line 15

def replace_with(hash)
  return hash if hash == @hash
  @changed = true
  @hash_copy = deep_dup hash
  @hash = hash
end