-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from bmaddy/lens_tests
changed lenses to a more OO style
- Loading branch information
Showing
11 changed files
with
578 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
require 'active_support/core_ext/hash' | ||
|
||
module FedoraLens | ||
class Lens < ActiveSupport::HashWithIndifferentAccess | ||
class Lens | ||
attr_reader(:options) | ||
|
||
def initialize(*options) | ||
@options = options | ||
end | ||
|
||
def get(source) | ||
self[:get].call(source) | ||
raise NotImplementedError.new | ||
end | ||
|
||
def put(source, value) | ||
self[:put].call(source, value) | ||
raise NotImplementedError.new | ||
end | ||
|
||
def create(value) | ||
self[:create].call(value) | ||
raise NotImplementedError.new | ||
end | ||
|
||
def ==(other_lens) | ||
self.class == other_lens.class && options == other_lens.options | ||
end | ||
end | ||
end |
Oops, something went wrong.