Class: Pinkman::Serializer::Scope
- Inherits:
-
Object
- Object
- Pinkman::Serializer::Scope
- Defined in:
- lib/pinkman/serializer/scope.rb
Instance Attribute Summary collapse
-
#access ⇒ Object
Returns the value of attribute access.
-
#read ⇒ Object
Returns the value of attribute read.
-
#serializer ⇒ Object
Returns the value of attribute serializer.
-
#write ⇒ Object
Returns the value of attribute write.
Instance Method Summary collapse
- #access_actions(*args) ⇒ Object
- #can_access ⇒ Object
- #can_access?(action) ⇒ Boolean
- #can_read ⇒ Object
- #can_read?(attribute) ⇒ Boolean
- #can_write ⇒ Object
- #can_write?(attribute) ⇒ Boolean
-
#initialize(hash) ⇒ Scope
constructor
A new instance of Scope.
- #read_attributes(*args) ⇒ Object
- #write_attributes(*args) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Scope
Returns a new instance of Scope.
5 6 7 |
# File 'lib/pinkman/serializer/scope.rb', line 5 def initialize hash self.serializer = hash[:serializer] if hash.is_a?(Hash) and hash[:serializer] end |
Instance Attribute Details
#access ⇒ Object
Returns the value of attribute access.
9 10 11 |
# File 'lib/pinkman/serializer/scope.rb', line 9 def access @access end |
#read ⇒ Object
Returns the value of attribute read.
9 10 11 |
# File 'lib/pinkman/serializer/scope.rb', line 9 def read @read end |
#serializer ⇒ Object
Returns the value of attribute serializer.
9 10 11 |
# File 'lib/pinkman/serializer/scope.rb', line 9 def serializer @serializer end |
#write ⇒ Object
Returns the value of attribute write.
9 10 11 |
# File 'lib/pinkman/serializer/scope.rb', line 9 def write @write end |
Instance Method Details
#access_actions(*args) ⇒ Object
23 24 25 26 27 |
# File 'lib/pinkman/serializer/scope.rb', line 23 def access_actions *args self.access = args self.access = [] unless args.first access end |
#can_access ⇒ Object
49 50 51 |
# File 'lib/pinkman/serializer/scope.rb', line 49 def can_access access end |
#can_access?(action) ⇒ Boolean
37 38 39 |
# File 'lib/pinkman/serializer/scope.rb', line 37 def can_access? action access.include?(:all) or access.include?(action.to_sym) end |
#can_read ⇒ Object
41 42 43 |
# File 'lib/pinkman/serializer/scope.rb', line 41 def can_read read end |
#can_read?(attribute) ⇒ Boolean
29 30 31 |
# File 'lib/pinkman/serializer/scope.rb', line 29 def can_read? attribute read.include?(:all) or read.include?(attribute.to_sym) or attribute.to_sym == :error or attribute.to_sym == :errors end |
#can_write ⇒ Object
45 46 47 |
# File 'lib/pinkman/serializer/scope.rb', line 45 def can_write write end |
#can_write?(attribute) ⇒ Boolean
33 34 35 |
# File 'lib/pinkman/serializer/scope.rb', line 33 def can_write? attribute (write.include?(:all) or write.include?(attribute.to_sym)) and (serializer.model.column_names.include?(attribute.to_s) or (serializer.model.instance_methods.include?("#{attribute.to_s}=".to_sym) and write.include?(attribute.to_sym))) end |
#read_attributes(*args) ⇒ Object
11 12 13 14 15 |
# File 'lib/pinkman/serializer/scope.rb', line 11 def read_attributes *args self.read = args self.read = [] unless args.first read end |
#write_attributes(*args) ⇒ Object
17 18 19 20 21 |
# File 'lib/pinkman/serializer/scope.rb', line 17 def write_attributes *args self.write = args self.write = [] unless args.first write end |